Commit 8a27cb38 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Optimization/fixing.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@6591 b35dd754-fafc-0310-a699-88a17e54d16e
parent 0edb79be
...@@ -39,8 +39,8 @@ import java.net.UnknownHostException; ...@@ -39,8 +39,8 @@ import java.net.UnknownHostException;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder; import java.nio.charset.CharsetEncoder;
import java.security.KeyStore; import java.security.KeyStore;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* Implementation of {@link Connection} inteface specific for NIO connections when using * Implementation of {@link Connection} inteface specific for NIO connections when using
...@@ -61,7 +61,7 @@ public class NIOConnection implements Connection { ...@@ -61,7 +61,7 @@ public class NIOConnection implements Connection {
private IoSession ioSession; private IoSession ioSession;
final private Map<ConnectionCloseListener, Object> listeners = final private Map<ConnectionCloseListener, Object> listeners =
new HashMap<ConnectionCloseListener, Object>(); new ConcurrentHashMap<ConnectionCloseListener, Object>();
/** /**
* Deliverer to use when the connection is closed or was closed when delivering * Deliverer to use when the connection is closed or was closed when delivering
...@@ -167,14 +167,12 @@ public class NIOConnection implements Connection { ...@@ -167,14 +167,12 @@ public class NIOConnection implements Connection {
* Used by subclasses to properly finish closing the connection. * Used by subclasses to properly finish closing the connection.
*/ */
private void notifyCloseListeners() { private void notifyCloseListeners() {
synchronized (listeners) { for (Map.Entry<ConnectionCloseListener,Object> entry : listeners.entrySet()) {
for (ConnectionCloseListener listener : listeners.keySet()) {
try { try {
listener.onConnectionClose(listeners.get(listener)); entry.getKey().onConnectionClose(entry.getValue());
} }
catch (Exception e) { catch (Exception e) {
Log.error("Error notifying listener: " + listener, e); Log.error("Error notifying listener: " + entry.getKey(), e);
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment