demery-pivotal commented on a change in pull request #7206:
URL: https://github.com/apache/geode/pull/7206#discussion_r771555548



##########
File path: 
geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientUserAuths.java
##########
@@ -97,21 +93,20 @@ public long putSubject(@NotNull Subject subject, long 
existingUniqueId) {
     return newId;
   }
 
-  public ClientUserAuths(int clientProxyHashcode) {
-    m_seed = clientProxyHashcode;
-    uniqueIdGenerator = new Random(m_seed + System.currentTimeMillis());
-    m_firstId = uniqueIdGenerator.nextLong();
+  public ClientUserAuths(SubjectIdGenerator idGenerator) {
+    this.idGenerator = idGenerator;
   }
 
-  synchronized long getNextID() {
-    final long uniqueId = uniqueIdGenerator.nextLong();
-    if (uniqueId == m_firstId) {
-      uniqueIdGenerator = new Random(m_seed + System.currentTimeMillis());
-      m_firstId = uniqueIdGenerator.nextLong();
+  private synchronized long getNextID() {
+    long uniqueId = idGenerator.generateId();
+    if (uniqueId == 0) {
+      uniqueId = idGenerator.generateId();

Review comment:
       The contract for an ID generator is to return unique IDs. If it can't do 
that, it must return -1 to indicate that it has exhausted all unique IDs. So a 
valid ID generator never returns the same ID twice (0 or otherwise) without 
first resetting itself and returning -1 to report ID exhaustion. 
   
   This contract is currently described only on the implementation of 
`RandomSubjectIdGenerator`. I will add it to the `SubjectIdGenerator` interface.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to