Attempt to resolve high-load UUIDGenerator problem. I was not able to reproduce the issue, but code inspection seems to indicate that this fix should work.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@559540 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Patrick Linskey 2007-07-25 17:56:20 +00:00
parent 3ddd88b576
commit 7a6a81d713
2 changed files with 12 additions and 1 deletions

View File

@ -172,10 +172,12 @@ public class UUIDGenerator {
*
* @return long timestamp
*/
private static long getTime() {
// package-visibility for testing
static long getTime() {
long newTime = getUUIDTime();
if (newTime <= _lastMillis) {
incrementSequence();
newTime = getUUIDTime();
}
_lastMillis = newTime;
return newTime;

View File

@ -41,4 +41,13 @@ public class TestUUIDGenerator extends TestCase {
for (int i = 0; i < 10000; i++)
assertTrue(seen.add(UUIDGenerator.nextHex()));
}
public void testGetTime() {
long time = 0;
for (int i = 0; i < 10000; i++) {
long newTime = UUIDGenerator.getTime();
assertTrue(newTime != time);
time = newTime;
}
}
}