removed the timer object in static block
Project: http://git-wip-us.apache.org/repos/asf/storm/repo Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/645e4a9d Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/645e4a9d Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/645e4a9d Branch: refs/heads/master Commit: 645e4a9d2271efcda897def11ffbb45a1ed5780d Parents: 54b6ac4 Author: Sanket <schintap@untilservice-lm> Authored: Tue Mar 8 16:34:49 2016 -0600 Committer: Sanket <schintap@untilservice-lm> Committed: Tue Mar 8 16:34:49 2016 -0600 ---------------------------------------------------------------------- .../jvm/org/apache/storm/messaging/netty/Client.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/storm/blob/645e4a9d/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 3e15d34..77c2bf5 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 @@ -115,7 +115,6 @@ public class Client extends ConnectionWithStatus implements IStatefulObject, ISa */ private final long CHANNEL_ALIVE_INTERVAL_MS = 30000L; - /** * Number of messages buffered in memory. */ @@ -139,10 +138,6 @@ public class Client extends ConnectionWithStatus implements IStatefulObject, ISa private final Object writeLock = new Object(); - static { - timer = new Timer("Netty-ChannelAlive-Timer", true); - } - @SuppressWarnings("rawtypes") Client(Map stormConf, ChannelFactory factory, HashedWheelTimer scheduler, String host, int port, Context context) { this.stormConf = stormConf; @@ -178,12 +173,20 @@ 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 { LOG.debug("running timer task, address {}", dstAddress); if(closing) { this.cancel(); + return; } getConnectedChannel(); } catch (Exception exp) {
