mirror of https://github.com/apache/openjpa.git
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:
parent
3ddd88b576
commit
7a6a81d713
|
@ -172,10 +172,12 @@ public class UUIDGenerator {
|
||||||
*
|
*
|
||||||
* @return long timestamp
|
* @return long timestamp
|
||||||
*/
|
*/
|
||||||
private static long getTime() {
|
// package-visibility for testing
|
||||||
|
static long getTime() {
|
||||||
long newTime = getUUIDTime();
|
long newTime = getUUIDTime();
|
||||||
if (newTime <= _lastMillis) {
|
if (newTime <= _lastMillis) {
|
||||||
incrementSequence();
|
incrementSequence();
|
||||||
|
newTime = getUUIDTime();
|
||||||
}
|
}
|
||||||
_lastMillis = newTime;
|
_lastMillis = newTime;
|
||||||
return newTime;
|
return newTime;
|
||||||
|
|
|
@ -41,4 +41,13 @@ public class TestUUIDGenerator extends TestCase {
|
||||||
for (int i = 0; i < 10000; i++)
|
for (int i = 0; i < 10000; i++)
|
||||||
assertTrue(seen.add(UUIDGenerator.nextHex()));
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue