diff --git a/src/main/java/org/zalando/nakadi/service/subscription/state/CleanupState.java b/src/main/java/org/zalando/nakadi/service/subscription/state/CleanupState.java index be517f2172..64d2fe96c6 100644 --- a/src/main/java/org/zalando/nakadi/service/subscription/state/CleanupState.java +++ b/src/main/java/org/zalando/nakadi/service/subscription/state/CleanupState.java @@ -20,11 +20,8 @@ public CleanupState(@Nullable final Exception e) { public void onEnter() { try { getContext().unregisterAuthorizationUpdates(); - getContext().getZkClient().close(); } catch (final RuntimeException ex) { getLog().error("Unexpected fail during removing callback for registration updates", ex); - } catch (IOException e) { - getLog().error("Unexpected fail to release zk connection", e); } try { if (null != exception) { @@ -36,6 +33,12 @@ public void onEnter() { } finally { switchState(StreamingContext.DEAD_STATE); } + + try { + getContext().getZkClient().close(); + } catch (final IOException e) { + getLog().error("Unexpected fail to release zk connection", e); + } } } }