diff options
author | Simone Bordet | 2015-10-30 10:18:16 +0000 |
---|---|---|
committer | Simone Bordet | 2015-10-30 10:18:16 +0000 |
commit | 0b95a9e23e25af3d1606785613d8035e29cbf9e8 (patch) | |
tree | 07aaaa0c3195f5d6ea92d3223d76f9e6a3812aa0 | |
parent | fa53b11850eab2162ce4e2c980aaf280c9355ceb (diff) | |
parent | 45cd1f1ce628ab3b04ffed1723d543d92f7730dd (diff) | |
download | org.eclipse.jetty.project-0b95a9e23e25af3d1606785613d8035e29cbf9e8.tar.gz org.eclipse.jetty.project-0b95a9e23e25af3d1606785613d8035e29cbf9e8.tar.xz org.eclipse.jetty.project-0b95a9e23e25af3d1606785613d8035e29cbf9e8.zip |
Merged branch 'jetty-9.3.x' into 'master'.
-rw-r--r-- | jetty-client/src/main/java/org/eclipse/jetty/client/DuplexConnectionPool.java | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/DuplexConnectionPool.java b/jetty-client/src/main/java/org/eclipse/jetty/client/DuplexConnectionPool.java index d887923e1c..dcf74709ce 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/DuplexConnectionPool.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/DuplexConnectionPool.java @@ -72,13 +72,29 @@ public class DuplexConnectionPool implements Closeable, Dumpable, Sweeper.Sweepa @ManagedAttribute(value = "The number of idle connections", readonly = true) public int getIdleConnectionCount() { - return idleConnections.size(); + lock(); + try + { + return idleConnections.size(); + } + finally + { + unlock(); + } } @ManagedAttribute(value = "The number of active connections", readonly = true) public int getActiveConnectionCount() { - return activeConnections.size(); + lock(); + try + { + return activeConnections.size(); + } + finally + { + unlock(); + } } public Queue<Connection> getIdleConnections() @@ -275,7 +291,7 @@ public class DuplexConnectionPool implements Closeable, Dumpable, Sweeper.Sweepa unlock(); } - if (activeRemoved) + if (activeRemoved || force) released(connection); boolean removed = activeRemoved || idleRemoved || force; if (removed) @@ -374,14 +390,14 @@ public class DuplexConnectionPool implements Closeable, Dumpable, Sweeper.Sweepa @Override public boolean sweep() { - List<Sweeper.Sweepable> toSweep = new ArrayList<>(); + List<Connection> toSweep = new ArrayList<>(); lock(); try { - for (Connection connection : getActiveConnections()) + for (Connection connection : activeConnections) { if (connection instanceof Sweeper.Sweepable) - toSweep.add(((Sweeper.Sweepable)connection)); + toSweep.add(connection); } } finally @@ -389,13 +405,13 @@ public class DuplexConnectionPool implements Closeable, Dumpable, Sweeper.Sweepa unlock(); } - for (Sweeper.Sweepable candidate : toSweep) + for (Connection connection : toSweep) { - if (candidate.sweep()) + if (((Sweeper.Sweepable)connection).sweep()) { - boolean removed = getActiveConnections().remove(candidate); + boolean removed = remove(connection, true); LOG.warn("Connection swept: {}{}{} from active connections{}{}", - candidate, + connection, System.lineSeparator(), removed ? "Removed" : "Not removed", System.lineSeparator(), |