[jboss-dev-forums] [Design of Messaging on JBoss (Messaging/JBoss)] - Re: UUIDGenerator broken on Windows...

jmesnil do-not-reply at jboss.com
Wed Feb 4 03:59:00 EST 2009


in UUIDGenerator.generateTimeBasedUUID, we use only the 1st 4 bytes of the address so that it works with IPv4 (4 bytes), IPv4 (16 bytes) and MAC (6 bytes).

The check on getHardwareAddress should be (address.length >= 4) so that we can safely use the byte array.

However, I'm surprised that Windows returns a 0-sized array.

Clebert, could you run this code on Java *6* on Windows to check what it returns:

   public static void main(String[] args) throws SocketException
   {
      
      Enumeration networkInterfaces = NetworkInterface.getNetworkInterfaces();
      while (networkInterfaces.hasMoreElements())
      {
         NetworkInterface networkInterface = (NetworkInterface)networkInterfaces.nextElement();
         byte[] hardwareAddress = networkInterface.getHardwareAddress();
         if (hardwareAddress == null)
         {
            System.out.println(networkInterface.getDisplayName() + ":null");
         } else 
         {
            String s = "";
            for (int i = 0; i < hardwareAddress.length - 1; i++)
            {
               s += Integer.toHexString(hardwareAddress) + ":";
            }
            s += hardwareAddress[hardwareAddress.length - 1];
            System.out.println(networkInterface.getDisplayName() + ":" + s);
         }
      }
   }

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4206823#4206823

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4206823



More information about the jboss-dev-forums mailing list