From: Alexandre Montplaisir Date: Thu, 19 May 2016 19:10:04 +0000 (-0400) Subject: Fix: Fix synchronization of LTTngAgent#dispose X-Git-Tag: v2.8.0~6 X-Git-Url: https://git.lttng.org/?p=lttng-ust.git;a=commitdiff_plain;h=c0016872320fcd9ade6d58bf654ff6db5e390918 Fix: Fix synchronization of LTTngAgent#dispose Commit 9355f049 changed the dispose() back to non-static. However, "static synchronized" and "synchronized" are not the same thing! The latter synchronizes on the instance, but the former synchronizes on the class object. In this case we need to synchronize on the class object manually. Signed-off-by: Alexandre Montplaisir Signed-off-by: Mathieu Desnoyers --- diff --git a/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/LTTngAgent.java b/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/LTTngAgent.java index c98301d7..6b4f0135 100644 --- a/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/LTTngAgent.java +++ b/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/LTTngAgent.java @@ -52,10 +52,12 @@ public class LTTngAgent { * logging. This dispose function is non-static for backwards * compatibility purposes. */ - public synchronized void dispose() { - if (instance != null) { - instance.disposeInstance(); - instance = null; + public void dispose() { + synchronized (LTTngAgent.class) { + if (instance != null) { + instance.disposeInstance(); + instance = null; + } } return; }