File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
src/main/java/com/gb/didgen/service Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ public class SnowflakeIdGenerator implements IdGenerator {
23
23
private final int generatingNodeId ;
24
24
private volatile long currentSequence ;
25
25
private final Object lock = new Object ();
26
- private volatile long lastTimestamp = 0L ;
26
+ private volatile long lastTimestamp ;
27
27
28
28
@ PostConstruct
29
29
public void checkNodeIdBounds () throws NodeIdOutOfBoundException {
@@ -33,7 +33,8 @@ public void checkNodeIdBounds() throws NodeIdOutOfBoundException {
33
33
}
34
34
35
35
@ Override
36
- public long generateId () throws ClockMovedBackException {
36
+ public long generateId () throws ClockMovedBackException , NodeIdOutOfBoundException {
37
+ checkNodeIdBounds ();
37
38
synchronized (lock ) {
38
39
long currentTimeStamp = getTimeStamp ();
39
40
if (currentTimeStamp < lastTimestamp ) {
You can’t perform that action at this time.
0 commit comments