This is an automated email from the ASF dual-hosted git repository.
tison pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/curator.git
The following commit(s) were added to refs/heads/master by this push:
new 0bb3adf37 GH-1248. Fix bug of useSessionTimeoutMs overflow (#1249)
0bb3adf37 is described below
commit 0bb3adf37877edd32c672c79fface4d748d3ed1a
Author: zbz <[email protected]>
AuthorDate: Fri Feb 28 13:01:45 2025 +0800
GH-1248. Fix bug of useSessionTimeoutMs overflow (#1249)
Co-authored-by: 赵宝珠 <[email protected]>
---
.../apache/curator/framework/state/ConnectionStateManager.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
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 ac963a213..c751296df 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