From b49957330f2fe80e872a5a3ceed0d0d07364cf08 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Tue, 6 May 2014 11:56:25 -0400 Subject: [PATCH] Fix: cleanup JUL agent state on sessiond disconnect Signed-off-by: David Goulet Signed-off-by: Mathieu Desnoyers --- .../org/lttng/ust/jul/LTTngLogHandler.java | 8 ++++++++ .../org/lttng/ust/jul/LTTngTCPSessiondClient.java | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/liblttng-ust-jul/org/lttng/ust/jul/LTTngLogHandler.java b/liblttng-ust-jul/org/lttng/ust/jul/LTTngLogHandler.java index b4e1c088..ddeb5eb3 100644 --- a/liblttng-ust-jul/org/lttng/ust/jul/LTTngLogHandler.java +++ b/liblttng-ust-jul/org/lttng/ust/jul/LTTngLogHandler.java @@ -83,6 +83,14 @@ public class LTTngLogHandler extends Handler { } } + /* + * Cleanup this handler state meaning put it back to a vanilla state. + */ + public void clear() { + this.eventMap.clear(); + this.logLevelsAll.clear(); + } + @Override public void close() throws SecurityException {} diff --git a/liblttng-ust-jul/org/lttng/ust/jul/LTTngTCPSessiondClient.java b/liblttng-ust-jul/org/lttng/ust/jul/LTTngTCPSessiondClient.java index f3ac80dc..5fdb0498 100644 --- a/liblttng-ust-jul/org/lttng/ust/jul/LTTngTCPSessiondClient.java +++ b/liblttng-ust-jul/org/lttng/ust/jul/LTTngTCPSessiondClient.java @@ -186,6 +186,17 @@ public class LTTngTCPSessiondClient { } } + /* + * Cleanup Agent state. + */ + private void cleanupState() { + enabledEventSet.clear(); + enabledLoggers.clear(); + if (this.handler != null) { + this.handler.clear(); + } + } + public void init(LTTngLogHandler handler) throws InterruptedException { this.handler = handler; @@ -194,6 +205,9 @@ public class LTTngTCPSessiondClient { break; } + /* Cleanup Agent state before trying to connect or reconnect. */ + cleanupState(); + try { /* -- 2.34.1