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 1a9bfd8f CURATOR-562. Follow up to cleanup
ConnectionState#checkTimeouts references (#429)
1a9bfd8f is described below
commit 1a9bfd8fa4be4889aa904dd087e3eea36dadb25b
Author: tison <[email protected]>
AuthorDate: Tue Jul 12 18:18:22 2022 +0800
CURATOR-562. Follow up to cleanup ConnectionState#checkTimeouts references
(#429)
Signed-off-by: tison <[email protected]>
---
.../curator/CuratorConnectionLossException.java | 4 --
.../framework/imps/CuratorFrameworkImpl.java | 44 +++++++++-------------
2 files changed, 18 insertions(+), 30 deletions(-)
diff --git
a/curator-client/src/main/java/org/apache/curator/CuratorConnectionLossException.java
b/curator-client/src/main/java/org/apache/curator/CuratorConnectionLossException.java
index 811140f8..bd5c7ae5 100644
---
a/curator-client/src/main/java/org/apache/curator/CuratorConnectionLossException.java
+++
b/curator-client/src/main/java/org/apache/curator/CuratorConnectionLossException.java
@@ -20,10 +20,6 @@ package org.apache.curator;
import org.apache.zookeeper.KeeperException;
-/**
- * This is needed to differentiate between ConnectionLossException thrown by
ZooKeeper
- * and ConnectionLossException thrown by {@link
ConnectionState#checkTimeouts()}
- */
public class CuratorConnectionLossException extends
KeeperException.ConnectionLossException
{
private static final long serialVersionUID = 1L;
diff --git
a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
index 9f4a8279..70cb4eb7 100644
---
a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
+++
b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
@@ -1006,44 +1006,36 @@ public class CuratorFrameworkImpl implements
CuratorFramework
if ( !operationAndData.isConnectionRequired() ||
client.isConnected() )
{
operationAndData.callPerformBackgroundOperation();
+ return;
}
- else
+
+ client.getZooKeeper(); // important - allow connection resets,
timeouts, etc. to occur
+ if ( operationAndData.getElapsedTimeMs() <
client.getConnectionTimeoutMs() )
{
- client.getZooKeeper(); // important - allow connection
resets, timeouts, etc. to occur
- if ( operationAndData.getElapsedTimeMs() >=
client.getConnectionTimeoutMs() )
- {
- throw new CuratorConnectionLossException();
- }
sleepAndQueueOperation(operationAndData);
+ return;
}
- }
- catch ( Throwable e )
- {
- ThreadUtils.checkInterrupted(e);
- /**
- * Fix edge case reported as CURATOR-52.
ConnectionState.checkTimeouts() throws KeeperException.ConnectionLossException
- * when the initial (or previously failed) connection cannot be
re-established. This needs to be run through the retry policy
- * and callbacks need to get invoked, etc.
+ /*
+ * Fix edge case reported as CURATOR-52. Connection timeout is
detected when the initial (or previously failed) connection
+ * cannot be re-established. This needs to be run through the
retry policy and callbacks need to get invoked, etc.
*/
- if ( e instanceof CuratorConnectionLossException )
+ WatchedEvent watchedEvent = new
WatchedEvent(Watcher.Event.EventType.None,
Watcher.Event.KeeperState.Disconnected, null);
+ CuratorEvent event = new CuratorEventImpl(this,
CuratorEventType.WATCHED, KeeperException.Code.CONNECTIONLOSS.intValue(), null,
null, operationAndData.getContext(), null, null, null, watchedEvent, null,
null);
+ if ( checkBackgroundRetry(operationAndData, event) )
{
- WatchedEvent watchedEvent = new
WatchedEvent(Watcher.Event.EventType.None,
Watcher.Event.KeeperState.Disconnected, null);
- CuratorEvent event = new CuratorEventImpl(this,
CuratorEventType.WATCHED, KeeperException.Code.CONNECTIONLOSS.intValue(), null,
null, operationAndData.getContext(), null, null, null, watchedEvent, null,
null);
- if ( checkBackgroundRetry(operationAndData, event) )
- {
- queueOperation(operationAndData);
- }
- else
- {
- logError("Background retry gave up", e);
- }
+ queueOperation(operationAndData);
}
else
{
- handleBackgroundOperationException(operationAndData, e);
+ logError("Background retry gave up", new
CuratorConnectionLossException());
}
}
+ catch ( Throwable e )
+ {
+ ThreadUtils.checkInterrupted(e);
+ handleBackgroundOperationException(operationAndData, e);
+ }
}
@VisibleForTesting