geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r740839 - /geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/XidFactoryImpl.java
Date Wed, 04 Feb 2009 19:48:11 GMT
Author: gawor
Date: Wed Feb  4 19:48:10 2009
New Revision: 740839

URL: http://svn.apache.org/viewvc?rev=740839&view=rev
Log:
add some random bytes to baseId. Patch from Gary Tully (GERONIMO-4393)

Modified:
    geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/XidFactoryImpl.java

Modified: geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/XidFactoryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/XidFactoryImpl.java?rev=740839&r1=740838&r2=740839&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/XidFactoryImpl.java
(original)
+++ geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/XidFactoryImpl.java
Wed Feb  4 19:48:10 2009
@@ -17,6 +17,7 @@
 
 package org.apache.geronimo.transaction.manager;
 
+import java.util.Random;
 import javax.transaction.xa.Xid;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
@@ -26,6 +27,7 @@
  * The Xid is constructed of three parts:
  * <ol><li>8 byte count (LSB first)</li>
  * <li>4 byte system id</li>
+ * <li>2 byte entropy</li>
  * <li>4 or 16 byte IP address of host</li>
  * <ol>
  * @version $Rev$ $Date$
@@ -51,7 +53,13 @@
         baseId[9] = (byte) (uid >>> 8);
         baseId[10] = (byte) (uid >>> 16);
         baseId[11] = (byte) (uid >>> 24);
-        System.arraycopy(hostid, 0, baseId, 12, hostid.length);
+
+        byte[] entropy = new byte[2];
+        new Random().nextBytes(entropy);
+        baseId[12] = entropy[0];
+        baseId[13] = entropy[1];
+
+        System.arraycopy(hostid, 0, baseId, 14, hostid.length);
     }
 
     public Xid createXid() {



Mime
View raw message