demery-pivotal commented on a change in pull request #7206:
URL: https://github.com/apache/geode/pull/7206#discussion_r771553277
##########
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();
+ }
+ if (uniqueId == -1) {
// now every user need to reauthenticate as we are short of Ids..
// though possibility of this is rare.
uniqueIdVsUserAuth.clear();
- return m_firstId;
+ return idGenerator.generateId();
Review comment:
The "contract" for `SubjectIdGenerator` is that it returns -1 only if it
exhausts all available IDs. So the only way it will return -1 twice in a row
only if it cannot generate any IDs in between the -1s.
I put "contract" in scare quotes because it's not written down anywhere. I
should probably add a comment on `SubjectIdGenerator` describing the contract.
--
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]