Randgalt commented on a change in pull request #363:
URL: https://github.com/apache/curator/pull/363#discussion_r421203375
##########
File path: curator-client/src/main/java/org/apache/curator/RetryPolicy.java
##########
@@ -33,5 +35,26 @@
* @param sleeper use this to sleep - DO NOT call Thread.sleep
* @return true/false
*/
- public boolean allowRetry(int retryCount, long elapsedTimeMs,
RetrySleeper sleeper);
+ boolean allowRetry(int retryCount, long elapsedTimeMs, RetrySleeper
sleeper);
+
+ /**
+ * Called when an operation has failed with a specific exception. This
method
+ * should return true to make another attempt.
+ *
+ * @param exception the cause that this operation failed
+ * @return true/false
+ */
+ default boolean allowRetry(Throwable exception)
+ {
+ if ( exception instanceof KeeperException)
+ {
+ final int rc = ((KeeperException) exception).code().intValue();
+ return (rc == KeeperException.Code.CONNECTIONLOSS.intValue()) ||
+ (rc == KeeperException.Code.OPERATIONTIMEOUT.intValue()) ||
+ (rc == KeeperException.Code.SESSIONMOVED.intValue()) ||
+ (rc == KeeperException.Code.SESSIONEXPIRED.intValue()) ||
+ (rc == -13); //
KeeperException.Code.NEWCONFIGNOQUORUM.intValue()) - using hard coded value for
ZK 3.4.x compatibility
Review comment:
Yes for sure
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]