File tree Expand file tree Collapse file tree 1 file changed +4
-9
lines changed
spring-core/src/main/java/org/springframework/util Expand file tree Collapse file tree 1 file changed +4
-9
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright 2002-2015 the original author or authors.
2+ * Copyright 2002-2020 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
2020import java .util .concurrent .atomic .AtomicLong ;
2121
2222/**
23- * A simple {@link IdGenerator} that starts at 1 and increments by 1 with each call.
23+ * A simple {@link IdGenerator} that starts at 1, increments up to
24+ * {@link Long#MAX_VALUE}, and then rolls over.
2425 *
2526 * @author Rossen Stoyanchev
2627 * @since 4.1.5
2728 */
2829public class SimpleIdGenerator implements IdGenerator {
2930
30- private final AtomicLong mostSigBits = new AtomicLong (0 );
31-
3231 private final AtomicLong leastSigBits = new AtomicLong (0 );
3332
3433
3534 @ Override
3635 public UUID generateId () {
37- long leastSigBits = this .leastSigBits .incrementAndGet ();
38- if (leastSigBits == 0 ) {
39- this .mostSigBits .incrementAndGet ();
40- }
41- return new UUID (this .mostSigBits .get (), leastSigBits );
36+ return new UUID (0 , this .leastSigBits .incrementAndGet ());
4237 }
4338
4439}
You can’t perform that action at this time.
0 commit comments