@@ -350,15 +350,21 @@ public static int _flip( int x ){
350350
351351 try {
352352 // build a 2-byte machine piece based on NICs info
353- final int machinePiece ;
353+ int machinePiece ;
354354 {
355- StringBuilder sb = new StringBuilder ();
356- Enumeration <NetworkInterface > e = NetworkInterface .getNetworkInterfaces ();
357- while ( e .hasMoreElements () ){
358- NetworkInterface ni = e .nextElement ();
359- sb .append ( ni .toString () );
355+ try {
356+ StringBuilder sb = new StringBuilder ();
357+ Enumeration <NetworkInterface > e = NetworkInterface .getNetworkInterfaces ();
358+ while ( e .hasMoreElements () ){
359+ NetworkInterface ni = e .nextElement ();
360+ sb .append ( ni .toString () );
361+ }
362+ machinePiece = sb .toString ().hashCode () << 16 ;
363+ } catch (Exception e ) {
364+ // exception sometimes happens with IBM JVM, use random
365+ LOGGER .log (Level .WARNING , e .getMessage (), e );
366+ machinePiece = (new Random ().nextInt ()) << 16 ;
360367 }
361- machinePiece = sb .toString ().hashCode () << 16 ;
362368 LOGGER .fine ( "machine piece post: " + Integer .toHexString ( machinePiece ) );
363369 }
364370
@@ -386,8 +392,8 @@ public static int _flip( int x ){
386392 _genmachine = machinePiece | processPiece ;
387393 LOGGER .fine ( "machine : " + Integer .toHexString ( _genmachine ) );
388394 }
389- catch ( java . io . IOException ioe ){
390- throw new RuntimeException ( ioe );
395+ catch ( Exception e ){
396+ throw new RuntimeException ( e );
391397 }
392398
393399 }
0 commit comments