From e07b3ce3cf63fff17b06c6a6289a52ae40d0f62e Mon Sep 17 00:00:00 2001 From: Heath Thomann Date: Thu, 1 Mar 2012 17:43:03 +0000 Subject: [PATCH] OPENJPA-2055: Added code to account for IPv6 addresses. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1295698 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/openjpa/lib/util/UUIDGenerator.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java index a9028a638..dbb26ac9d 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java @@ -118,7 +118,13 @@ public class UUIDGenerator { IP = new byte[6]; RANDOM.nextBytes(IP); - System.arraycopy(ip, 0, IP, 2, ip.length); + + //OPENJPA-2055: account for the fact that 'getAddress' + //may return an IPv6 address which is 16 bytes wide. + for( int i = 0 ; i < ip.length; ++i ) { + IP[2+(i%4)] ^= ip[i]; + } + type1Initialized = true; }