Skip to content

Commit 49321f1

Browse files
committed
[grid] Using DefaultSlotMatcher in DockerSessionFactory
With this, all places where matching is done are now using the same logic for matching. Next step is to retrieve the matching class from the configuration. Fixes #10307
1 parent caf8d47 commit 49321f1

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

java/src/org/openqa/selenium/grid/node/docker/DockerSessionFactory.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import org.openqa.selenium.docker.Image;
4040
import org.openqa.selenium.docker.Port;
4141
import org.openqa.selenium.grid.data.CreateSessionRequest;
42+
import org.openqa.selenium.grid.data.DefaultSlotMatcher;
43+
import org.openqa.selenium.grid.data.SlotMatcher;
4244
import org.openqa.selenium.grid.node.ActiveSession;
4345
import org.openqa.selenium.grid.node.SessionFactory;
4446
import org.openqa.selenium.internal.Either;
@@ -77,7 +79,6 @@
7779
import java.util.Collections;
7880
import java.util.HashMap;
7981
import java.util.Map;
80-
import java.util.Objects;
8182
import java.util.Optional;
8283
import java.util.TimeZone;
8384
import java.util.logging.Level;
@@ -97,6 +98,7 @@ public class DockerSessionFactory implements SessionFactory {
9798
private final DockerAssetsPath assetsPath;
9899
private final String networkName;
99100
private final boolean runningInDocker;
101+
private final SlotMatcher slotMatcher;
100102

101103
public DockerSessionFactory(
102104
Tracer tracer,
@@ -120,16 +122,12 @@ public DockerSessionFactory(
120122
this.videoImage = videoImage;
121123
this.assetsPath = assetsPath;
122124
this.runningInDocker = runningInDocker;
125+
this.slotMatcher = new DefaultSlotMatcher();
123126
}
124127

125128
@Override
126129
public boolean test(Capabilities capabilities) {
127-
return stereotype.getCapabilityNames().stream()
128-
.map(
129-
name ->
130-
Objects.equals(stereotype.getCapability(name), capabilities.getCapability(name)))
131-
.reduce(Boolean::logicalAnd)
132-
.orElse(false);
130+
return slotMatcher.matches(stereotype, capabilities);
133131
}
134132

135133
@Override

0 commit comments

Comments
 (0)