fix for ConnectionInfo.cleanup of server-connections

pull/1/head
sixcooler 11 years ago
parent 6f707b4305
commit eb9d2705d2

@ -289,16 +289,17 @@ public class ConnectionInfo implements Comparable<ConnectionInfo> {
* removes stale connections * removes stale connections
*/ */
public static void cleanUp() { public static void cleanUp() {
cleanup(getAllConnections().iterator()); cleanup(getAllConnections());
cleanup(getServerConnections().iterator()); cleanup(getServerConnections());
} }
private static void cleanup(final Iterator<ConnectionInfo> iter) { private static void cleanup(final Set<ConnectionInfo> connectionSet) {
final Iterator<ConnectionInfo> iter = connectionSet.iterator();
synchronized (iter) { synchronized (iter) {
while (iter.hasNext()) try { while (iter.hasNext()) try {
ConnectionInfo con = iter.next(); ConnectionInfo con = iter.next();
if(con.getLifetime() > staleAfterMillis) { if(con.getLifetime() > staleAfterMillis) {
getAllConnections().remove(con); connectionSet.remove(con);
} }
} catch (ConcurrentModificationException e) {} } catch (ConcurrentModificationException e) {}
} }

Loading…
Cancel
Save