From: Alexandre Montplaisir Date: Thu, 19 May 2016 19:10:04 +0000 (-0400) Subject: Fix: Fix synchronization of LTTngAgent#dispose X-Git-Tag: v2.9.0-rc1~98 X-Git-Url: http://git.liburcu.org/?p=lttng-ust.git;a=commitdiff_plain;h=6b4fc51ebf77552964eeebc13caa68f7fd9012cf 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; }