You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by "tisonkun (via GitHub)" <gi...@apache.org> on 2025/02/27 00:18:14 UTC
Re: [PR] GH-1248. Fix bug of useSessionTimeoutMs overflow [curator]
tisonkun commented on PR #1249:
URL: https://github.com/apache/curator/pull/1249#issuecomment-2686496766
Something like this:
```diff
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
```
--
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: commits-unsubscribe@curator.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org