Fix: Fix synchronization of LTTngAgent#dispose
authorAlexandre Montplaisir <alexmonthy@efficios.com>
Thu, 19 May 2016 19:10:04 +0000 (15:10 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 19 May 2016 19:52:20 +0000 (15:52 -0400)
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 <alexmonthy@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/LTTngAgent.java

index c98301d738b8aa3a81f17ce240e687c88a047794..6b4f0135de08e4f05ffd0fa8ab472f55d6ddd212 100644 (file)
@@ -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;
        }
This page took 0.026443 seconds and 4 git commands to generate.