-
Notifications
You must be signed in to change notification settings - Fork 1.3k
GH-1248. Fix bug of useSessionTimeoutMs overflow #1249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tisonkun
merged 1 commit into
apache:master
from
xingsuo-zbz:bugfix/useSessionTimeoutMs-overflow
Feb 28, 2025
Merged
GH-1248. Fix bug of useSessionTimeoutMs overflow #1249
tisonkun
merged 1 commit into
apache:master
from
xingsuo-zbz:bugfix/useSessionTimeoutMs-overflow
Feb 28, 2025
+5
−5
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
Author
|
Hi, @tisonkun Could you please help me review it? |
tisonkun
reviewed
Feb 27, 2025
Member
tisonkun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the usage I suppose we can simply change the signature of getUseSessionTimeoutMs to return a long and use long inside.
Member
|
Something like this: diff --git a/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java b/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java
index ac963a21..c751296d 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java
@@ -241,7 +241,7 @@ public class ConnectionStateManager implements Closeable {
private void processEvents() {
while (state.get() == State.STARTED) {
try {
- int useSessionTimeoutMs = getUseSessionTimeoutMs();
+ long useSessionTimeoutMs = getUseSessionTimeoutMs();
long elapsedMs = startOfSuspendedEpoch == 0
? useSessionTimeoutMs / 2
: System.currentTimeMillis() - startOfSuspendedEpoch;
@@ -281,7 +281,7 @@ public class ConnectionStateManager implements Closeable {
private void checkSessionExpiration() {
if ((currentConnectionState == ConnectionState.SUSPENDED) && (startOfSuspendedEpoch != 0)) {
long elapsedMs = System.currentTimeMillis() - startOfSuspendedEpoch;
- int useSessionTimeoutMs = getUseSessionTimeoutMs();
+ long useSessionTimeoutMs = getUseSessionTimeoutMs();
if (elapsedMs >= useSessionTimeoutMs) {
startOfSuspendedEpoch =
System.currentTimeMillis(); // reset startOfSuspendedEpoch to avoid spinning on this session
@@ -317,9 +317,9 @@ public class ConnectionStateManager implements Closeable {
startOfSuspendedEpoch = (currentConnectionState == ConnectionState.SUSPENDED) ? System.currentTimeMillis() : 0;
}
- private int getUseSessionTimeoutMs() {
- int lastNegotiatedSessionTimeoutMs = client.getZookeeperClient().getLastNegotiatedSessionTimeoutMs();
- int useSessionTimeoutMs =
+ private long getUseSessionTimeoutMs() {
+ long lastNegotiatedSessionTimeoutMs = client.getZookeeperClient().getLastNegotiatedSessionTimeoutMs();
+ long useSessionTimeoutMs =
(lastNegotiatedSessionTimeoutMs > 0) ? lastNegotiatedSessionTimeoutMs : sessionTimeoutMs;
useSessionTimeoutMs = sessionExpirationPercent > 0 && startOfSuspendedEpoch != 0
? (useSessionTimeoutMs * sessionExpirationPercent) / 100 |
39cf51a to
e50507c
Compare
Contributor
Author
|
@tisonkun thanks,Changes done as discussed. Please review again. |
tisonkun
approved these changes
Feb 27, 2025
kezhuw
approved these changes
Feb 28, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix bug of useSessionTimeoutMs overflow.
This closes #1248.