commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joe...@apache.org
Subject svn commit: r370241 - /jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/serial/TimeBasedAlphanumericIdentifierGenerator.java
Date Wed, 18 Jan 2006 20:02:57 GMT
Author: joehni
Date: Wed Jan 18 12:02:53 2006
New Revision: 370241

URL: http://svn.apache.org/viewcvs?rev=370241&view=rev
Log:
Fix behaviour during time shifts resulting in duplicate ids.

Modified:
    jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/serial/TimeBasedAlphanumericIdentifierGenerator.java

Modified: jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/serial/TimeBasedAlphanumericIdentifierGenerator.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/serial/TimeBasedAlphanumericIdentifierGenerator.java?rev=370241&r1=370240&r2=370241&view=diff
==============================================================================
--- jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/serial/TimeBasedAlphanumericIdentifierGenerator.java
(original)
+++ jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/serial/TimeBasedAlphanumericIdentifierGenerator.java
Wed Jan 18 12:02:53 2006
@@ -80,7 +80,7 @@
      */
     private final int postfixSize;
     private final long offset;
-
+    
     /**
      * Construct a TimeBasedAlphanumericIdentifierGenerator with a defined size of the postfix
and
      * an offset for the time value. The offset can be used to manipulate the representation
of the
@@ -130,7 +130,7 @@
     }
 
     public String nextStringIdentifier() {
-        final long now;
+        long now;
         synchronized (this) {
             now = Calendar.getInstance(UTC).getTime().getTime(); // JDK 1.3 compatibility
             final long diff = now - last;
@@ -139,6 +139,9 @@
                 last = now;
                 counter = 0;
             } else {
+                if (diff != 0) {
+                    now = last; // ignore time shift
+                }
                 ++counter;
             }
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message