Skip to content

Commit 61380d4

Browse files
committed
Simplify the logic as review comment
Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent 9fbb738 commit 61380d4

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

java/src/org/openqa/selenium/grid/distributor/local/LocalNodeRegistry.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -361,15 +361,8 @@ public Set<NodeStatus> getAvailableNodes() {
361361
readLock.lock();
362362
try {
363363
return model.getSnapshot().stream()
364-
.filter(
365-
node -> {
366-
// Only consider UP nodes (not DOWN, DRAINING, etc.)
367-
if (!UP.equals(node.getAvailability())) {
368-
return false;
369-
}
370-
// Consider node has at least one free slot
371-
return node.getSlots().stream().anyMatch(slot -> slot.getSession() == null);
372-
})
364+
// Filter nodes are UP and have capacity (available slots)
365+
.filter(node -> UP.equals(node.getAvailability()) && node.hasCapacity())
373366
.collect(ImmutableSet.toImmutableSet());
374367
} finally {
375368
readLock.unlock();

0 commit comments

Comments
 (0)