[jboss-cvs] JBoss Messaging SVN: r5818 - trunk/src/main/org/jboss/messaging/util.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 5 11:11:06 EST 2009


Author: jmesnil
Date: 2009-02-05 11:11:06 -0500 (Thu, 05 Feb 2009)
New Revision: 5818

Modified:
   trunk/src/main/org/jboss/messaging/util/UUIDGenerator.java
Log:
use hardware address only from a up non-loopback non-virtual network interface

Modified: trunk/src/main/org/jboss/messaging/util/UUIDGenerator.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/UUIDGenerator.java	2009-02-05 10:02:58 UTC (rev 5817)
+++ trunk/src/main/org/jboss/messaging/util/UUIDGenerator.java	2009-02-05 16:11:06 UTC (rev 5818)
@@ -127,9 +127,15 @@
    public final static byte[] getHardwareAddress()
    {
       Method getHardwareAddressMethod;
+      Method isUpMethod;
+      Method isLoopbackMethod;
+      Method isVirtualMethod;
       try
       {
          getHardwareAddressMethod = NetworkInterface.class.getMethod("getHardwareAddress");
+         isUpMethod = NetworkInterface.class.getMethod("isUp");
+         isLoopbackMethod = NetworkInterface.class.getMethod("isLoopback");
+         isVirtualMethod = NetworkInterface.class.getMethod("isVirtual");
       }
       catch (Throwable t)
       {
@@ -143,6 +149,15 @@
          while (networkInterfaces.hasMoreElements())
          {
             NetworkInterface networkInterface = (NetworkInterface)networkInterfaces.nextElement();
+            boolean up = (Boolean)isUpMethod.invoke(networkInterface);
+            boolean loopback = (Boolean)isLoopbackMethod.invoke(networkInterface);
+            boolean virtual = (Boolean)isVirtualMethod.invoke(networkInterface);
+            
+            if (loopback || virtual || !up)
+            {
+               continue;
+            }
+            
             Object res = getHardwareAddressMethod.invoke(networkInterface);
             if (res != null && res instanceof byte[])
             {




More information about the jboss-cvs-commits mailing list