fix tests I broke; refactor a few other pieces

I broke serveral tests with 8f4142f87e
so I'm restoring that, and I'm refactoring a few other pieces so the
code is simpler and/or more correct.
This commit is contained in:
jbertram 2015-01-28 16:08:45 -06:00
parent 8bdad8897e
commit e17e3ba4f6
1 changed files with 4 additions and 5 deletions

View File

@ -400,8 +400,7 @@ public class RemotingServiceImpl implements RemotingService, ConnectionLifeCycle
if (!conn.isClient()) if (!conn.isClient())
{ {
conn.disconnect(scaleDownNodeID, false); conn.disconnect(scaleDownNodeID, false);
connections.remove(entry.getKey()); removeConnection(entry.getKey());
connectionCountLatch.countDown();
} }
} }
} }
@ -508,10 +507,10 @@ public class RemotingServiceImpl implements RemotingService, ConnectionLifeCycle
public RemotingConnection removeConnection(final Object remotingConnectionID) public RemotingConnection removeConnection(final Object remotingConnectionID)
{ {
ConnectionEntry entry = connections.remove(remotingConnectionID); ConnectionEntry entry = connections.remove(remotingConnectionID);
connectionCountLatch.countDown();
if (entry != null) if (entry != null)
{ {
connectionCountLatch.countDown();
return entry.connection; return entry.connection;
} }
else else
@ -604,8 +603,7 @@ public class RemotingServiceImpl implements RemotingService, ConnectionLifeCycle
// so we need to keep them for ttl, in case re-attachment occurs // so we need to keep them for ttl, in case re-attachment occurs
if (empty) if (empty)
{ {
connections.remove(connectionID); removeConnection(connectionID);
connectionCountLatch.countDown();
conn.connection.destroy(); conn.connection.destroy();
} }
@ -789,6 +787,7 @@ public class RemotingServiceImpl implements RemotingService, ConnectionLifeCycle
if (conn != null) if (conn != null)
{ {
conn.fail(ActiveMQMessageBundle.BUNDLE.clientExited(conn.getRemoteAddress())); conn.fail(ActiveMQMessageBundle.BUNDLE.clientExited(conn.getRemoteAddress()));
removeConnection(id);
} }
} }