From 6b4fc51ebf77552964eeebc13caa68f7fd9012cf Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Thu, 19 May 2016 15:10:04 -0400 Subject: [PATCH] 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 --- .../org/lttng/ust/agent/LTTngAgent.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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; } -- 2.34.1