From 35d2b921ea90eb42ff09b1d77bb70fef827eb22f Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Mon, 1 Feb 2016 16:12:01 -0500 Subject: [PATCH] NIFI-259: Distinguish between unable to communicate with ZK and 'bad version' when performing 'replace' method of ZooKeeperStateProvider Signed-off-by: Aldrin Piri --- .../providers/zookeeper/ZooKeeperStateProvider.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/state/providers/zookeeper/ZooKeeperStateProvider.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/state/providers/zookeeper/ZooKeeperStateProvider.java index 239b68a759..27727a7d7d 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/state/providers/zookeeper/ZooKeeperStateProvider.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/state/providers/zookeeper/ZooKeeperStateProvider.java @@ -439,7 +439,15 @@ public class ZooKeeperStateProvider extends AbstractStateProvider { setState(newValue, (int) oldValue.getVersion(), componentId); return true; } catch (final IOException ioe) { - return false; + final Throwable cause = ioe.getCause(); + if (cause != null && cause instanceof KeeperException) { + final KeeperException ke = (KeeperException) cause; + if (Code.BADVERSION == ke.code()) { + return false; + } + } + + throw ioe; } }