You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2016/01/13 21:21:08 UTC
curator git commit: General fix for catch-alls throughout the code.
This is overkill but it strikes me as the safest way to address the problem.
Everywhere there is a catch-all add a check for InterruptedException and
reset the thread's interrupted state
Repository: curator
Updated Branches:
refs/heads/CURATOR-208 [created] 003acc602
General fix for catch-alls throughout the code. This is overkill but it strikes me as the safest way to address the problem. Everywhere there is a catch-all add a check for InterruptedException and reset the thread's interrupted state
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/003acc60
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/003acc60
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/003acc60
Branch: refs/heads/CURATOR-208
Commit: 003acc6027aa63e59b5de3b0d1da7e33c2b9f9cc
Parents: 45332f3
Author: randgalt <ra...@apache.org>
Authored: Wed Jan 13 15:20:54 2016 -0500
Committer: randgalt <ra...@apache.org>
Committed: Wed Jan 13 15:20:54 2016 -0500
----------------------------------------------------------------------
.../org/apache/curator/ConnectionState.java | 4 ++++
.../apache/curator/CuratorZookeeperClient.java | 2 ++
.../main/java/org/apache/curator/RetryLoop.java | 2 ++
.../apache/curator/SessionFailRetryLoop.java | 2 ++
.../exhibitor/ExhibitorEnsembleProvider.java | 2 ++
.../org/apache/curator/utils/ThreadUtils.java | 8 +++++++
.../src/main/java/locking/LockingExample.java | 7 +++++-
.../curator/framework/imps/Backgrounding.java | 2 ++
.../framework/imps/CreateBuilderImpl.java | 3 +++
.../framework/imps/CuratorFrameworkImpl.java | 9 ++++++-
.../framework/imps/DeleteBuilderImpl.java | 2 ++
.../framework/imps/FailedDeleteManager.java | 2 ++
.../FindAndDeleteProtectedNodeInBackground.java | 2 ++
.../framework/imps/GetDataBuilderImpl.java | 2 ++
.../curator/framework/imps/NamespaceImpl.java | 2 ++
.../framework/imps/NamespaceWatcher.java | 2 ++
.../framework/listen/ListenerContainer.java | 2 ++
.../recipes/AfterConnectionEstablished.java | 1 +
.../framework/recipes/cache/NodeCache.java | 4 ++++
.../recipes/cache/PathChildrenCache.java | 4 ++++
.../framework/recipes/cache/TreeCache.java | 7 ++++++
.../framework/recipes/leader/LeaderLatch.java | 5 ++++
.../recipes/leader/LeaderSelector.java | 10 ++++----
.../framework/recipes/locks/ChildReaper.java | 1 +
.../recipes/locks/InterProcessMultiLock.java | 4 ++++
.../recipes/locks/InterProcessSemaphore.java | 4 ++++
.../recipes/locks/InterProcessSemaphoreV2.java | 2 ++
.../framework/recipes/locks/LockInternals.java | 2 ++
.../curator/framework/recipes/locks/Reaper.java | 1 +
.../framework/recipes/nodes/GroupMember.java | 3 +++
.../recipes/nodes/PersistentEphemeralNode.java | 3 +++
.../recipes/queue/DistributedQueue.java | 4 ++++
.../framework/recipes/queue/QueueSharder.java | 2 ++
.../framework/recipes/shared/SharedValue.java | 2 ++
.../entity/JsonServiceInstanceMarshaller.java | 3 +++
.../entity/JsonServiceInstancesMarshaller.java | 2 ++
.../server/rest/DiscoveryResource.java | 6 +++++
.../discovery/server/rest/InstanceCleanup.java | 2 ++
.../discovery/details/ServiceDiscoveryImpl.java | 3 +++
.../x/rpc/idl/discovery/DiscoveryService.java | 8 +++++++
.../idl/discovery/DiscoveryServiceLowLevel.java | 7 ++++++
.../idl/services/CuratorProjectionService.java | 25 ++++++++++++++++++++
42 files changed, 162 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-client/src/main/java/org/apache/curator/ConnectionState.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/ConnectionState.java b/curator-client/src/main/java/org/apache/curator/ConnectionState.java
index 46ae9fd..dc6ac53 100644
--- a/curator-client/src/main/java/org/apache/curator/ConnectionState.java
+++ b/curator-client/src/main/java/org/apache/curator/ConnectionState.java
@@ -22,6 +22,7 @@ import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.drivers.TracerDriver;
import org.apache.curator.ensemble.EnsembleProvider;
import org.apache.curator.utils.DebugUtils;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.curator.utils.ZookeeperFactory;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
@@ -114,6 +115,7 @@ class ConnectionState implements Watcher, Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new IOException(e);
}
finally
@@ -277,6 +279,7 @@ class ConnectionState implements Watcher, Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
queueBackgroundException(e);
}
}
@@ -292,6 +295,7 @@ class ConnectionState implements Watcher, Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
queueBackgroundException(e);
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java b/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
index 09b28b2..c9f5199 100644
--- a/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
+++ b/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
@@ -24,6 +24,7 @@ import org.apache.curator.ensemble.EnsembleProvider;
import org.apache.curator.ensemble.fixed.FixedEnsembleProvider;
import org.apache.curator.utils.DefaultTracerDriver;
import org.apache.curator.utils.DefaultZookeeperFactory;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.curator.utils.ZookeeperFactory;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
@@ -203,6 +204,7 @@ public class CuratorZookeeperClient implements Closeable
}
catch ( IOException e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("", e);
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-client/src/main/java/org/apache/curator/RetryLoop.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/RetryLoop.java b/curator-client/src/main/java/org/apache/curator/RetryLoop.java
index 6b66e82..48d4d5c 100644
--- a/curator-client/src/main/java/org/apache/curator/RetryLoop.java
+++ b/curator-client/src/main/java/org/apache/curator/RetryLoop.java
@@ -20,6 +20,7 @@ package org.apache.curator;
import org.apache.curator.drivers.TracerDriver;
import org.apache.curator.utils.DebugUtils;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.zookeeper.KeeperException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -109,6 +110,7 @@ public class RetryLoop
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
retryLoop.takeException(e);
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-client/src/main/java/org/apache/curator/SessionFailRetryLoop.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/SessionFailRetryLoop.java b/curator-client/src/main/java/org/apache/curator/SessionFailRetryLoop.java
index 8647952..7fa1275 100644
--- a/curator-client/src/main/java/org/apache/curator/SessionFailRetryLoop.java
+++ b/curator-client/src/main/java/org/apache/curator/SessionFailRetryLoop.java
@@ -21,6 +21,7 @@ package org.apache.curator;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
@@ -159,6 +160,7 @@ public class SessionFailRetryLoop implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
retryLoop.takeException(e);
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-client/src/main/java/org/apache/curator/ensemble/exhibitor/ExhibitorEnsembleProvider.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/ensemble/exhibitor/ExhibitorEnsembleProvider.java b/curator-client/src/main/java/org/apache/curator/ensemble/exhibitor/ExhibitorEnsembleProvider.java
index 02a01e5..9c3ec34 100644
--- a/curator-client/src/main/java/org/apache/curator/ensemble/exhibitor/ExhibitorEnsembleProvider.java
+++ b/curator-client/src/main/java/org/apache/curator/ensemble/exhibitor/ExhibitorEnsembleProvider.java
@@ -251,6 +251,7 @@ public class ExhibitorEnsembleProvider implements EnsembleProvider
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Couldn't get backup connection string", e);
}
return values;
@@ -303,6 +304,7 @@ public class ExhibitorEnsembleProvider implements EnsembleProvider
}
catch ( Throwable e )
{
+ ThreadUtils.checkInterrupted(e);
if ( retryPolicy.allowRetry(retries++, System.currentTimeMillis() - start, RetryLoop.getDefaultRetrySleeper()) )
{
log.warn("Couldn't get servers from Exhibitor. Retrying.", e);
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-client/src/main/java/org/apache/curator/utils/ThreadUtils.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/utils/ThreadUtils.java b/curator-client/src/main/java/org/apache/curator/utils/ThreadUtils.java
index 8960ec0..24efd50 100644
--- a/curator-client/src/main/java/org/apache/curator/utils/ThreadUtils.java
+++ b/curator-client/src/main/java/org/apache/curator/utils/ThreadUtils.java
@@ -26,6 +26,14 @@ import java.util.concurrent.ThreadFactory;
public class ThreadUtils
{
+ public static void checkInterrupted(Throwable e)
+ {
+ if ( e instanceof InterruptedException )
+ {
+ Thread.currentThread().interrupt();
+ }
+ }
+
public static ExecutorService newSingleThreadExecutor(String processName)
{
return Executors.newSingleThreadExecutor(newThreadFactory(processName));
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-examples/src/main/java/locking/LockingExample.java
----------------------------------------------------------------------
diff --git a/curator-examples/src/main/java/locking/LockingExample.java b/curator-examples/src/main/java/locking/LockingExample.java
index dfe0801..d400c43 100644
--- a/curator-examples/src/main/java/locking/LockingExample.java
+++ b/curator-examples/src/main/java/locking/LockingExample.java
@@ -65,9 +65,14 @@ public class LockingExample
example.doWork(10, TimeUnit.SECONDS);
}
}
- catch ( Throwable e )
+ catch ( InterruptedException e )
+ {
+ Thread.currentThread().interrupt();
+ }
+ catch ( Exception e )
{
e.printStackTrace();
+ // log or do something
}
finally
{
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-framework/src/main/java/org/apache/curator/framework/imps/Backgrounding.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/Backgrounding.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/Backgrounding.java
index 262b2a8..1bb2423 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/Backgrounding.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/Backgrounding.java
@@ -21,6 +21,7 @@ package org.apache.curator.framework.imps;
import org.apache.curator.framework.api.BackgroundCallback;
import org.apache.curator.framework.api.CuratorEvent;
import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.zookeeper.KeeperException;
import java.util.concurrent.Executor;
@@ -110,6 +111,7 @@ class Backgrounding
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
if ( e instanceof KeeperException )
{
client.validateConnection(client.codeToState(((KeeperException)e).code()));
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java
index a9cb600..eeb057d 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java
@@ -28,6 +28,7 @@ import org.apache.curator.framework.api.*;
import org.apache.curator.framework.api.transaction.CuratorTransactionBridge;
import org.apache.curator.framework.api.transaction.OperationType;
import org.apache.curator.framework.api.transaction.TransactionCreateBuilder;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.curator.utils.ZKPaths;
import org.apache.zookeeper.AsyncCallback;
import org.apache.zookeeper.CreateMode;
@@ -477,6 +478,7 @@ class CreateBuilderImpl implements CreateBuilder, BackgroundOperation<PathAndByt
}
catch ( Exception e)
{
+ ThreadUtils.checkInterrupted(e);
if ( ( e instanceof KeeperException.ConnectionLossException ||
!( e instanceof KeeperException )) && protectedId != null )
{
@@ -667,6 +669,7 @@ class CreateBuilderImpl implements CreateBuilder, BackgroundOperation<PathAndByt
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
client.logError("Processing protected create for path: " + givenPath, e);
}
callSuper = false;
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
----------------------------------------------------------------------
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 9c017d0..dddcfe4 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
@@ -271,6 +271,7 @@ public class CuratorFrameworkImpl implements CuratorFramework
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
handleBackgroundOperationException(null, e);
}
}
@@ -293,6 +294,7 @@ public class CuratorFrameworkImpl implements CuratorFramework
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Exception while sending Closing event", e);
}
return null;
@@ -725,8 +727,9 @@ public class CuratorFrameworkImpl implements CuratorFramework
{
e = (code != null) ? KeeperException.create(code) : null;
}
- catch ( Throwable ignore )
+ catch ( Throwable t )
{
+ ThreadUtils.checkInterrupted(t);
}
if ( e == null )
{
@@ -747,6 +750,7 @@ public class CuratorFrameworkImpl implements CuratorFramework
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
handleBackgroundOperationException(operationAndData, e);
}
}
@@ -832,6 +836,8 @@ public class CuratorFrameworkImpl implements CuratorFramework
}
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
@@ -877,6 +883,7 @@ public class CuratorFrameworkImpl implements CuratorFramework
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
logError("Event listener threw exception", e);
}
return null;
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-framework/src/main/java/org/apache/curator/framework/imps/DeleteBuilderImpl.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/DeleteBuilderImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/DeleteBuilderImpl.java
index 9db0013..c3247a1 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/DeleteBuilderImpl.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/DeleteBuilderImpl.java
@@ -31,6 +31,7 @@ import org.apache.curator.framework.api.Pathable;
import org.apache.curator.framework.api.transaction.CuratorTransactionBridge;
import org.apache.curator.framework.api.transaction.OperationType;
import org.apache.curator.framework.api.transaction.TransactionDeleteBuilder;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.curator.utils.ZKPaths;
import org.apache.zookeeper.AsyncCallback;
import org.apache.zookeeper.KeeperException;
@@ -259,6 +260,7 @@ class DeleteBuilderImpl implements DeleteBuilder, BackgroundOperation<String>
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
//Only retry a guaranteed delete if it's a retryable error
if( (RetryLoop.isRetryException(e) || (e instanceof InterruptedException)) && guaranteed )
{
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-framework/src/main/java/org/apache/curator/framework/imps/FailedDeleteManager.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/FailedDeleteManager.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/FailedDeleteManager.java
index deb7f40..ecf8fb3 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/FailedDeleteManager.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/FailedDeleteManager.java
@@ -19,6 +19,7 @@
package org.apache.curator.framework.imps;
import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.utils.ThreadUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,6 +57,7 @@ class FailedDeleteManager
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
addFailedDelete(path);
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-framework/src/main/java/org/apache/curator/framework/imps/FindAndDeleteProtectedNodeInBackground.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/FindAndDeleteProtectedNodeInBackground.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/FindAndDeleteProtectedNodeInBackground.java
index 7b5073b..2fbd9dd 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/FindAndDeleteProtectedNodeInBackground.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/FindAndDeleteProtectedNodeInBackground.java
@@ -21,6 +21,7 @@ package org.apache.curator.framework.imps;
import com.google.common.annotations.VisibleForTesting;
import org.apache.curator.TimeTrace;
import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.curator.utils.ZKPaths;
import org.apache.zookeeper.AsyncCallback;
import org.apache.zookeeper.KeeperException;
@@ -89,6 +90,7 @@ class FindAndDeleteProtectedNodeInBackground implements BackgroundOperation<Void
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Could not start guaranteed delete for node: " + node);
rc = KeeperException.Code.CONNECTIONLOSS.intValue();
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-framework/src/main/java/org/apache/curator/framework/imps/GetDataBuilderImpl.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/GetDataBuilderImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/GetDataBuilderImpl.java
index e994b03..5a8d16c 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/GetDataBuilderImpl.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/GetDataBuilderImpl.java
@@ -29,6 +29,7 @@ import org.apache.curator.framework.api.GetDataBuilder;
import org.apache.curator.framework.api.GetDataWatchBackgroundStatable;
import org.apache.curator.framework.api.Pathable;
import org.apache.curator.framework.api.WatchPathable;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.zookeeper.AsyncCallback;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.Watcher;
@@ -246,6 +247,7 @@ class GetDataBuilderImpl implements GetDataBuilder, BackgroundOperation<String>
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Decompressing for path: " + path, e);
rc = KeeperException.Code.DATAINCONSISTENCY.intValue();
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceImpl.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceImpl.java
index 74f6320..ba6150a 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceImpl.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceImpl.java
@@ -23,6 +23,7 @@ import org.apache.curator.RetryLoop;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.utils.EnsurePath;
import org.apache.curator.utils.PathUtils;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.curator.utils.ZKPaths;
import org.apache.zookeeper.ZooDefs;
import java.util.concurrent.Callable;
@@ -95,6 +96,7 @@ class NamespaceImpl
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
client.logError("Ensure path threw exception", e);
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceWatcher.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceWatcher.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceWatcher.java
index 299e28b..1cb9125 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceWatcher.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceWatcher.java
@@ -19,6 +19,7 @@
package org.apache.curator.framework.imps;
import org.apache.curator.framework.api.CuratorWatcher;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import java.io.Closeable;
@@ -68,6 +69,7 @@ class NamespaceWatcher implements Watcher, Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
client.logError("Watcher exception", e);
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-framework/src/main/java/org/apache/curator/framework/listen/ListenerContainer.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/listen/ListenerContainer.java b/curator-framework/src/main/java/org/apache/curator/framework/listen/ListenerContainer.java
index ed477e5..549ed81 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/listen/ListenerContainer.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/listen/ListenerContainer.java
@@ -21,6 +21,7 @@ package org.apache.curator.framework.listen;
import com.google.common.base.Function;
import com.google.common.collect.Maps;
import com.google.common.util.concurrent.MoreExecutors;
+import org.apache.curator.utils.ThreadUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
@@ -93,6 +94,7 @@ public class ListenerContainer<T> implements Listenable<T>
}
catch ( Throwable e )
{
+ ThreadUtils.checkInterrupted(e);
log.error(String.format("Listener (%s) threw an exception", entry.listener), e);
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-recipes/src/main/java/org/apache/curator/framework/recipes/AfterConnectionEstablished.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/AfterConnectionEstablished.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/AfterConnectionEstablished.java
index 65c6ace..64ee449 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/AfterConnectionEstablished.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/AfterConnectionEstablished.java
@@ -57,6 +57,7 @@ public class AfterConnectionEstablished
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("An error occurred blocking until a connection is available", e);
}
finally
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/NodeCache.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/NodeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/NodeCache.java
index bfc27d8..eb81893 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/NodeCache.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/NodeCache.java
@@ -30,6 +30,7 @@ import org.apache.curator.framework.listen.ListenerContainer;
import org.apache.curator.framework.state.ConnectionState;
import org.apache.curator.framework.state.ConnectionStateListener;
import org.apache.curator.utils.PathUtils;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
@@ -77,6 +78,7 @@ public class NodeCache implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Trying to reset after reconnection", e);
}
}
@@ -99,6 +101,7 @@ public class NodeCache implements Closeable
}
catch(Exception e)
{
+ ThreadUtils.checkInterrupted(e);
handleException(e);
}
}
@@ -309,6 +312,7 @@ public class NodeCache implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Calling listener", e);
}
return null;
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
index 3ee6b6d..12769e1 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
@@ -118,6 +118,7 @@ public class PathChildrenCache implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
handleException(e);
}
}
@@ -519,6 +520,7 @@ public class PathChildrenCache implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
handleException(e);
}
return null;
@@ -644,6 +646,7 @@ public class PathChildrenCache implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
handleException(e);
}
break;
@@ -777,6 +780,7 @@ public class PathChildrenCache implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
handleException(e);
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
index 4f3ffb6..cbab483 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
@@ -347,6 +347,7 @@ public class TreeCache implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
handleException(e);
}
}
@@ -575,6 +576,7 @@ public class TreeCache implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
handleException(e);
}
}
@@ -710,6 +712,7 @@ public class TreeCache implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
handleException(e);
}
return null;
@@ -739,6 +742,7 @@ public class TreeCache implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
LOG.error("Exception handling exception", e);
}
return null;
@@ -766,6 +770,7 @@ public class TreeCache implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
handleException(e);
}
break;
@@ -778,6 +783,7 @@ public class TreeCache implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
handleException(e);
}
break;
@@ -815,6 +821,7 @@ public class TreeCache implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
handleException(e);
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java
index a6d8145..7f507bb 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java
@@ -32,6 +32,7 @@ import org.apache.curator.framework.recipes.locks.LockInternalsSorter;
import org.apache.curator.framework.recipes.locks.StandardLockInternalsDriver;
import org.apache.curator.framework.state.ConnectionState;
import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.curator.utils.ZKPaths;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
@@ -209,6 +210,7 @@ public class LeaderLatch implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new IOException(e);
}
finally
@@ -514,6 +516,7 @@ public class LeaderLatch implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("An error occurred checking resetting leadership.", e);
}
}
@@ -549,6 +552,7 @@ public class LeaderLatch implements Closeable
}
catch ( Exception ex )
{
+ ThreadUtils.checkInterrupted(ex);
log.error("An error occurred checking the leadership.", ex);
}
}
@@ -606,6 +610,7 @@ public class LeaderLatch implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Could not reset leader latch", e);
setLeadership(false);
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderSelector.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderSelector.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderSelector.java
index 716ca96..ec33533 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderSelector.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderSelector.java
@@ -405,7 +405,7 @@ public class LeaderSelector implements Closeable
}
catch ( Throwable e )
{
- log.error("The leader threw an exception", e);
+ ThreadUtils.checkInterrupted(e);
}
finally
{
@@ -417,10 +417,6 @@ public class LeaderSelector implements Closeable
Thread.currentThread().interrupt();
throw e;
}
- catch ( Exception e )
- {
- throw e;
- }
finally
{
hasLeadership = false;
@@ -428,8 +424,10 @@ public class LeaderSelector implements Closeable
{
mutex.release();
}
- catch ( Exception ignore )
+ catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
+ log.error("The leader threw an exception", e);
// ignore errors - this is just a safety
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/ChildReaper.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/ChildReaper.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/ChildReaper.java
index 9d196e8..3c8b56a 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/ChildReaper.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/ChildReaper.java
@@ -283,6 +283,7 @@ public class ChildReaper implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Could not get children for path: " + path, e);
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMultiLock.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMultiLock.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMultiLock.java
index f400a1a..47e84af 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMultiLock.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMultiLock.java
@@ -21,6 +21,7 @@ package org.apache.curator.framework.recipes.locks;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.utils.ThreadUtils;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -110,6 +111,7 @@ public class InterProcessMultiLock implements InterProcessLock
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
success = false;
exception = e;
}
@@ -125,6 +127,7 @@ public class InterProcessMultiLock implements InterProcessLock
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
// ignore
}
}
@@ -156,6 +159,7 @@ public class InterProcessMultiLock implements InterProcessLock
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
if ( baseException == null )
{
baseException = e;
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessSemaphore.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessSemaphore.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessSemaphore.java
index 3d29aa8..4d1f064 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessSemaphore.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessSemaphore.java
@@ -25,6 +25,7 @@ import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.shared.SharedCountListener;
import org.apache.curator.framework.recipes.shared.SharedCountReader;
import org.apache.curator.framework.state.ConnectionState;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.zookeeper.KeeperException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -183,6 +184,7 @@ public class InterProcessSemaphore
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
returnAll(builder.build());
throw e;
}
@@ -250,6 +252,7 @@ public class InterProcessSemaphore
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
returnAll(builder.build());
throw e;
}
@@ -274,6 +277,7 @@ public class InterProcessSemaphore
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new IOException(e);
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessSemaphoreV2.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessSemaphoreV2.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessSemaphoreV2.java
index f4af39b..8524075 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessSemaphoreV2.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessSemaphoreV2.java
@@ -31,6 +31,7 @@ import org.apache.curator.framework.imps.CuratorFrameworkState;
import org.apache.curator.framework.recipes.shared.SharedCountListener;
import org.apache.curator.framework.recipes.shared.SharedCountReader;
import org.apache.curator.framework.state.ConnectionState;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.curator.utils.ZKPaths;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
@@ -413,6 +414,7 @@ public class InterProcessSemaphoreV2
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new IOException(e);
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
index 2b4d3d9..f712945 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
@@ -27,6 +27,7 @@ import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.api.CuratorWatcher;
import org.apache.curator.framework.imps.CuratorFrameworkState;
import org.apache.curator.utils.PathUtils;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.curator.utils.ZKPaths;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
@@ -317,6 +318,7 @@ public class LockInternals
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
doDelete = true;
throw e;
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/Reaper.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/Reaper.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/Reaper.java
index a7a575f..2522154 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/Reaper.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/Reaper.java
@@ -315,6 +315,7 @@ public class Reaper implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Trying to reap: " + holder.path, e);
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/GroupMember.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/GroupMember.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/GroupMember.java
index b914ba4..8cd1f65 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/GroupMember.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/GroupMember.java
@@ -26,6 +26,7 @@ import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.recipes.cache.ChildData;
import org.apache.curator.framework.recipes.cache.PathChildrenCache;
import org.apache.curator.utils.CloseableUtils;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.curator.utils.ZKPaths;
import java.io.Closeable;
import java.util.Map;
@@ -77,6 +78,7 @@ public class GroupMember implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
Throwables.propagate(e);
}
}
@@ -94,6 +96,7 @@ public class GroupMember implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
Throwables.propagate(e);
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentEphemeralNode.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentEphemeralNode.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentEphemeralNode.java
index 684e0d9..cc1159a 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentEphemeralNode.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentEphemeralNode.java
@@ -30,6 +30,7 @@ import org.apache.curator.framework.api.CuratorWatcher;
import org.apache.curator.framework.state.ConnectionState;
import org.apache.curator.framework.state.ConnectionStateListener;
import org.apache.curator.utils.PathUtils;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
@@ -325,6 +326,7 @@ public class PersistentEphemeralNode implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new IOException(e);
}
}
@@ -396,6 +398,7 @@ public class PersistentEphemeralNode implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RuntimeException("Creating node. BasePath: " + basePath, e); // should never happen unless there's a programming error - so throw RuntimeException
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/DistributedQueue.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/DistributedQueue.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/DistributedQueue.java
index 3b63956..43291e4 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/DistributedQueue.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/DistributedQueue.java
@@ -31,6 +31,7 @@ import org.apache.curator.framework.api.CuratorEventType;
import org.apache.curator.framework.imps.CuratorFrameworkState;
import org.apache.curator.framework.listen.ListenerContainer;
import org.apache.curator.framework.recipes.leader.LeaderSelector;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.curator.utils.ZKPaths;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
@@ -633,6 +634,7 @@ public class DistributedQueue<T> implements QueueBase<T>
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Error processing message at " + itemNode, e);
}
finally
@@ -663,6 +665,7 @@ public class DistributedQueue<T> implements QueueBase<T>
}
catch ( Throwable e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Corrupted queue item: " + itemNode, e);
return resultCode;
}
@@ -681,6 +684,7 @@ public class DistributedQueue<T> implements QueueBase<T>
}
catch ( Throwable e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Exception processing queue item: " + itemNode, e);
if ( errorMode.get() == ErrorMode.REQUEUE )
{
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/QueueSharder.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/QueueSharder.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/QueueSharder.java
index 455794c..24a56f8 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/QueueSharder.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/QueueSharder.java
@@ -26,6 +26,7 @@ import com.google.common.collect.Sets;
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.curator.utils.ZKPaths;
import org.apache.zookeeper.data.Stat;
import org.slf4j.Logger;
@@ -279,6 +280,7 @@ public class QueueSharder<U, T extends QueueBase<U>> implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Checking queue counts against threshold", e);
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java
index 6ce6bf4..17a2943 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java
@@ -27,6 +27,7 @@ import org.apache.curator.framework.listen.ListenerContainer;
import org.apache.curator.framework.state.ConnectionState;
import org.apache.curator.framework.state.ConnectionStateListener;
import org.apache.curator.utils.PathUtils;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.data.Stat;
@@ -261,6 +262,7 @@ public class SharedValue implements Closeable, SharedValueReader
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("From SharedValue listener", e);
}
return null;
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/entity/JsonServiceInstanceMarshaller.java
----------------------------------------------------------------------
diff --git a/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/entity/JsonServiceInstanceMarshaller.java b/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/entity/JsonServiceInstanceMarshaller.java
index f461d04..44c1034 100644
--- a/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/entity/JsonServiceInstanceMarshaller.java
+++ b/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/entity/JsonServiceInstanceMarshaller.java
@@ -18,6 +18,7 @@
*/
package org.apache.curator.x.discovery.server.entity;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.curator.x.discovery.ServiceInstance;
import org.apache.curator.x.discovery.ServiceInstanceBuilder;
import org.apache.curator.x.discovery.ServiceType;
@@ -95,6 +96,7 @@ public class JsonServiceInstanceMarshaller<T> implements MessageBodyReader<Servi
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new WebApplicationException(e);
}
@@ -144,6 +146,7 @@ public class JsonServiceInstanceMarshaller<T> implements MessageBodyReader<Servi
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new WebApplicationException(e);
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/entity/JsonServiceInstancesMarshaller.java
----------------------------------------------------------------------
diff --git a/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/entity/JsonServiceInstancesMarshaller.java b/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/entity/JsonServiceInstancesMarshaller.java
index 168e508..b00608a 100644
--- a/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/entity/JsonServiceInstancesMarshaller.java
+++ b/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/entity/JsonServiceInstancesMarshaller.java
@@ -19,6 +19,7 @@
package org.apache.curator.x.discovery.server.entity;
import com.google.common.collect.Lists;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.curator.x.discovery.ServiceInstance;
import org.apache.curator.x.discovery.server.rest.DiscoveryContext;
import org.codehaus.jackson.JsonNode;
@@ -91,6 +92,7 @@ public class JsonServiceInstancesMarshaller<T> implements MessageBodyReader<Serv
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new WebApplicationException(e);
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/rest/DiscoveryResource.java
----------------------------------------------------------------------
diff --git a/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/rest/DiscoveryResource.java b/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/rest/DiscoveryResource.java
index 271b827..b4d9cb7 100644
--- a/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/rest/DiscoveryResource.java
+++ b/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/rest/DiscoveryResource.java
@@ -19,6 +19,7 @@
package org.apache.curator.x.discovery.server.rest;
import com.google.common.collect.Lists;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.curator.x.discovery.ServiceInstance;
import org.apache.curator.x.discovery.ServiceType;
import org.apache.curator.x.discovery.details.InstanceProvider;
@@ -101,6 +102,7 @@ public abstract class DiscoveryResource<T>
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Trying to register service", e);
return Response.serverError().build();
}
@@ -123,6 +125,7 @@ public abstract class DiscoveryResource<T>
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Trying to delete service", e);
return Response.serverError().build();
}
@@ -176,6 +179,7 @@ public abstract class DiscoveryResource<T>
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error(String.format("Trying to get instances from service (%s)", name), e);
return Response.serverError().build();
}
@@ -208,6 +212,7 @@ public abstract class DiscoveryResource<T>
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error(String.format("Trying to get any instance from service (%s)", name), e);
return Response.serverError().build();
}
@@ -231,6 +236,7 @@ public abstract class DiscoveryResource<T>
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error(String.format("Trying to get instance (%s) from service (%s)", id, name), e);
return Response.serverError().build();
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/rest/InstanceCleanup.java
----------------------------------------------------------------------
diff --git a/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/rest/InstanceCleanup.java b/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/rest/InstanceCleanup.java
index a4de7a6..827ed35 100644
--- a/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/rest/InstanceCleanup.java
+++ b/curator-x-discovery-server/src/main/java/org/apache/curator/x/discovery/server/rest/InstanceCleanup.java
@@ -96,6 +96,7 @@ public class InstanceCleanup implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("GC for service names", e);
}
}
@@ -118,6 +119,7 @@ public class InstanceCleanup implements Closeable
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error(String.format("GC for service: %s", name), e);
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java
----------------------------------------------------------------------
diff --git a/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java b/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java
index 21c9e07..de81612 100644
--- a/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java
+++ b/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java
@@ -79,6 +79,7 @@ public class ServiceDiscoveryImpl<T> implements ServiceDiscovery<T>
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Could not re-register instances after reconnection", e);
}
}
@@ -160,6 +161,7 @@ public class ServiceDiscoveryImpl<T> implements ServiceDiscovery<T>
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Could not unregister instance: " + entry.service.getName(), e);
}
}
@@ -458,6 +460,7 @@ public class ServiceDiscoveryImpl<T> implements ServiceDiscovery<T>
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Could not start node cache for: " + instance, e);
}
NodeCacheListener listener = new NodeCacheListener()
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/discovery/DiscoveryService.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/discovery/DiscoveryService.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/discovery/DiscoveryService.java
index ca9f4b0..22f732d 100644
--- a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/discovery/DiscoveryService.java
+++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/discovery/DiscoveryService.java
@@ -23,6 +23,7 @@ import com.facebook.swift.service.ThriftService;
import com.google.common.base.Function;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.curator.x.discovery.DownInstancePolicy;
import org.apache.curator.x.discovery.ProviderStrategy;
import org.apache.curator.x.discovery.ServiceDiscovery;
@@ -70,6 +71,7 @@ public class DiscoveryService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -109,6 +111,7 @@ public class DiscoveryService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -168,6 +171,7 @@ public class DiscoveryService
}
catch ( IOException e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Could not close ServiceProvider with serviceName: " + serviceName, e);
}
}
@@ -177,6 +181,7 @@ public class DiscoveryService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -193,6 +198,7 @@ public class DiscoveryService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -222,6 +228,7 @@ public class DiscoveryService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -245,6 +252,7 @@ public class DiscoveryService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/discovery/DiscoveryServiceLowLevel.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/discovery/DiscoveryServiceLowLevel.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/discovery/DiscoveryServiceLowLevel.java
index 5ed6b88..42c90b9 100644
--- a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/discovery/DiscoveryServiceLowLevel.java
+++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/discovery/DiscoveryServiceLowLevel.java
@@ -23,6 +23,7 @@ import com.facebook.swift.service.ThriftService;
import com.google.common.base.Function;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
+import org.apache.curator.utils.ThreadUtils;
import org.apache.curator.x.discovery.ServiceDiscovery;
import org.apache.curator.x.discovery.ServiceInstance;
import org.apache.curator.x.rpc.connections.ConnectionManager;
@@ -53,6 +54,7 @@ public class DiscoveryServiceLowLevel
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -69,6 +71,7 @@ public class DiscoveryServiceLowLevel
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -85,6 +88,7 @@ public class DiscoveryServiceLowLevel
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -101,6 +105,7 @@ public class DiscoveryServiceLowLevel
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -117,6 +122,7 @@ public class DiscoveryServiceLowLevel
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -146,6 +152,7 @@ public class DiscoveryServiceLowLevel
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/003acc60/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/services/CuratorProjectionService.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/services/CuratorProjectionService.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/services/CuratorProjectionService.java
index eb67341..794b467 100644
--- a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/services/CuratorProjectionService.java
+++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/services/CuratorProjectionService.java
@@ -153,6 +153,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -184,6 +185,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -220,6 +222,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -257,6 +260,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -285,6 +289,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -314,6 +319,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -329,6 +335,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -351,6 +358,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -380,6 +388,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Could not release left-over lock for path: " + path, e);
}
}
@@ -390,6 +399,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -415,6 +425,7 @@ public class CuratorProjectionService
}
catch ( IOException e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Could not close left-over leader latch for path: " + path, e);
}
}
@@ -446,6 +457,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -475,6 +487,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -491,6 +504,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -516,6 +530,7 @@ public class CuratorProjectionService
}
catch ( IOException e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Could not close left-over PathChildrenCache for path: " + path, e);
}
}
@@ -536,6 +551,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -563,6 +579,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -579,6 +596,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -604,6 +622,7 @@ public class CuratorProjectionService
}
catch ( IOException e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Could not close left-over NodeCache for path: " + path, e);
}
}
@@ -624,6 +643,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -640,6 +660,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -665,6 +686,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Could not release left-over persistent ephemeral node for path: " + path, e);
}
}
@@ -674,6 +696,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}
@@ -706,6 +729,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
log.error("Could not release semaphore leases for path: " + path, e);
}
}
@@ -716,6 +740,7 @@ public class CuratorProjectionService
}
catch ( Exception e )
{
+ ThreadUtils.checkInterrupted(e);
throw new RpcException(e);
}
}