[grid] Don't fail node status when a session stops mid-read LocalNode.getStatus checks slot.isAvailable() and then calls slot.getSession(), which checks again and throws NoSuchSessionException when the session was released on another thread in between. That fails the whole status call, and LocalNodeTest.canStopASession and isNotOwnerOfAStoppedSession flake on Windows when they poll the status while the stop is still finishing. Treat the slot as free in that case.
diff --git a/java/src/org/openqa/selenium/grid/node/local/LocalNode.java b/java/src/org/openqa/selenium/grid/node/local/LocalNode.java index d997c70..b32d706 100644 --- a/java/src/org/openqa/selenium/grid/node/local/LocalNode.java +++ b/java/src/org/openqa/selenium/grid/node/local/LocalNode.java
@@ -1311,7 +1311,14 @@ public NodeStatus getStatus() { Instant lastStarted = Instant.EPOCH; Session session = null; if (!slot.isAvailable()) { - ActiveSession activeSession = slot.getSession(); + ActiveSession activeSession; + try { + activeSession = slot.getSession(); + } catch (NoSuchSessionException e) { + // The session stopped on another thread after isAvailable() was checked, so + // the slot is free again. + activeSession = null; + } if (activeSession != null) { lastStarted = activeSession.getStartTime(); session =