@@ -350,15 +350,21 @@ public static int _flip( int x ){
350
350
351
351
try {
352
352
// build a 2-byte machine piece based on NICs info
353
- final int machinePiece ;
353
+ int machinePiece ;
354
354
{
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 ;
360
367
}
361
- machinePiece = sb .toString ().hashCode () << 16 ;
362
368
LOGGER .fine ( "machine piece post: " + Integer .toHexString ( machinePiece ) );
363
369
}
364
370
@@ -386,8 +392,8 @@ public static int _flip( int x ){
386
392
_genmachine = machinePiece | processPiece ;
387
393
LOGGER .fine ( "machine : " + Integer .toHexString ( _genmachine ) );
388
394
}
389
- catch ( java . io . IOException ioe ){
390
- throw new RuntimeException ( ioe );
395
+ catch ( Exception e ){
396
+ throw new RuntimeException ( e );
391
397
}
392
398
393
399
}
0 commit comments