From 1c2164adad63ccf592334f8ee3376254e26445d9 Mon Sep 17 00:00:00 2001 From: kurobako Date: Fri, 4 Mar 2016 23:44:16 +0100 Subject: [PATCH] Removing Synchronization performed on java.util.concurrent.ConcurrentLinkedDeque object in class NettyConnection --- .../remoting/impl/netty/NettyConnection.java | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java index 45334eeb92..92686995c1 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java @@ -18,8 +18,8 @@ package org.apache.activemq.artemis.core.remoting.impl.netty; import java.net.SocketAddress; import java.util.Deque; +import java.util.LinkedList; import java.util.Map; -import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.Semaphore; import io.netty.buffer.ByteBuf; @@ -71,7 +71,7 @@ public class NettyConnection implements Connection { /** if {@link #isWritable(ReadyListener)} returns false, we add a callback * here for when the connection (or Netty Channel) becomes available again. */ - private final Deque readyListeners = new LinkedBlockingDeque<>(); + private final Deque readyListeners = new LinkedList<>(); // Static -------------------------------------------------------- @@ -102,34 +102,30 @@ public class NettyConnection implements Connection { @Override - public boolean isWritable(ReadyListener callback) { - synchronized (readyListeners) { - if (!ready) { - readyListeners.push(callback); - } - - return ready; + public synchronized boolean isWritable(ReadyListener callback) { + if (!ready) { + readyListeners.push(callback); } + + return ready; } @Override - public void fireReady(final boolean ready) { - synchronized (readyListeners) { - this.ready = ready; + public synchronized void fireReady(final boolean ready) { + this.ready = ready; - if (ready) { - for (;;) { - ReadyListener readyListener = readyListeners.poll(); - if (readyListener == null) { - return; - } + if (ready) { + for (;;) { + ReadyListener readyListener = readyListeners.poll(); + if (readyListener == null) { + return; + } - try { - readyListener.readyForWriting(); - } - catch (Throwable logOnly) { - ActiveMQClientLogger.LOGGER.warn(logOnly.getMessage(), logOnly); - } + try { + readyListener.readyForWriting(); + } + catch (Throwable logOnly) { + ActiveMQClientLogger.LOGGER.warn(logOnly.getMessage(), logOnly); } } }