File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
java/src/org/openqa/selenium/grid/node/local Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -377,8 +377,10 @@ public boolean isReady() {
377377 @ VisibleForTesting
378378 @ ManagedAttribute (name = "CurrentSessions" )
379379 public int getCurrentSessionCount () {
380+ // we need the exact size, see javadoc of Cache.size
381+ long n = currentSessions .asMap ().values ().stream ().count ();
380382 // It seems wildly unlikely we'll overflow an int
381- return Math .toIntExact (currentSessions . size () );
383+ return Math .toIntExact (n );
382384 }
383385
384386 @ VisibleForTesting
@@ -1005,6 +1007,9 @@ public HealthCheck getHealthCheck() {
10051007 public void drain () {
10061008 bus .fire (new NodeDrainStarted (getId ()));
10071009 draining = true ;
1010+ // Ensure the pendingSessions counter will not be decremented by timed out sessions not included
1011+ // in the currentSessionCount and the NodeDrainComplete will be raised to early.
1012+ currentSessions .cleanUp ();
10081013 int currentSessionCount = getCurrentSessionCount ();
10091014 if (currentSessionCount == 0 ) {
10101015 LOG .info ("Firing node drain complete message" );
You can’t perform that action at this time.
0 commit comments