From 8a11a83188a3985d29cd82ad09dfcb1dff1da146 Mon Sep 17 00:00:00 2001 From: Andrey Dyachkov Date: Thu, 20 Jun 2019 18:12:03 +0200 Subject: [PATCH 1/2] close zk session at the last step --- .../nakadi/service/subscription/state/CleanupState.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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..e89360affb 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) { @@ -33,6 +30,9 @@ public void onEnter() { } finally { try { getContext().unregisterSession(); + getContext().getZkClient().close(); + } catch (IOException e) { + getLog().error("Unexpected fail to release zk connection", e); } finally { switchState(StreamingContext.DEAD_STATE); } From cda8d12c397be6eba582aaa51336fe90eb7b539a Mon Sep 17 00:00:00 2001 From: Andrey Dyachkov Date: Fri, 21 Jun 2019 09:16:06 +0200 Subject: [PATCH 2/2] close zk client after unregistering seesion --- .../nakadi/service/subscription/state/CleanupState.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 e89360affb..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 @@ -30,12 +30,15 @@ public void onEnter() { } finally { try { getContext().unregisterSession(); - getContext().getZkClient().close(); - } catch (IOException e) { - getLog().error("Unexpected fail to release zk connection", e); } finally { switchState(StreamingContext.DEAD_STATE); } + + try { + getContext().getZkClient().close(); + } catch (final IOException e) { + getLog().error("Unexpected fail to release zk connection", e); + } } } }