avoid race condition double check locking

Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/072fcc88
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/072fcc88
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/072fcc88

Branch: refs/heads/master
Commit: 072fcc8865d5e2ebc606ab5b88dad5ff0ef551d4
Parents: 645e4a9
Author: Sanket <schintap@untilservice-lm>
Authored: Wed Mar 9 12:07:52 2016 -0600
Committer: Sanket <schintap@untilservice-lm>
Committed: Wed Mar 9 12:07:52 2016 -0600

----------------------------------------------------------------------
 .../src/jvm/org/apache/storm/messaging/netty/Client.java    | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/072fcc88/storm-core/src/jvm/org/apache/storm/messaging/netty/Client.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/messaging/netty/Client.java 
b/storm-core/src/jvm/org/apache/storm/messaging/netty/Client.java
index 77c2bf5..035eb1b 100644
--- a/storm-core/src/jvm/org/apache/storm/messaging/netty/Client.java
+++ b/storm-core/src/jvm/org/apache/storm/messaging/netty/Client.java
@@ -75,7 +75,7 @@ public class Client extends ConnectionWithStatus implements 
IStatefulObject, ISa
     private static final Logger LOG = LoggerFactory.getLogger(Client.class);
     private static final String PREFIX = "Netty-Client-";
     private static final long NO_DELAY_MS = 0L;
-    private static Timer timer;
+    private static final Timer timer = new Timer("Netty-ChannelAlive-Timer", 
true);
 
     private final Map stormConf;
     private final StormBoundedExponentialBackoffRetry retryPolicy;
@@ -173,13 +173,6 @@ public class Client extends ConnectionWithStatus 
implements IStatefulObject, ISa
     private void launchChannelAliveThread() {
         // netty TimerTask is already defined and hence a fully
         // qualified name
-        if (timer == null) {
-            synchronized (Client.class) {
-                if (timer == null) {
-                    timer = new Timer("Netty-ChannelAlive-Timer", true);
-                }
-            }
-        }
         timer.schedule(new java.util.TimerTask() {
             public void run() {
                 try {

Reply via email to