Skip to content

Commit 001963b

Browse files
authored
[java] Avoid using ServiceLoader while creating FirefoxDriver instance
Fixes #10010 and #10301
1 parent a14ed61 commit 001963b

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

‎java/src/org/openqa/selenium/firefox/FirefoxDriver.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@
5555
import java.nio.file.Path;
5656
import java.util.Map;
5757
import java.util.Optional;
58-
import java.util.ServiceLoader;
59-
import java.util.stream.StreamSupport;
6058

6159
/**
6260
* An implementation of the {#link WebDriver} interface that drives Firefox.
@@ -103,8 +101,9 @@ public FirefoxDriver(FirefoxDriverService service, Capabilities desiredCapabilit
103101
Require.nonNull("Driver service", service),
104102
new FirefoxOptions(desiredCapabilities));
105103
}
104+
106105
public FirefoxDriver(FirefoxOptions options) {
107-
this(toExecutor(options), options);
106+
this(new FirefoxDriverCommandExecutor(GeckoDriverService.createDefaultService()), options);
108107
}
109108

110109
public FirefoxDriver(FirefoxDriverService service) {
@@ -141,18 +140,6 @@ public static RemoteWebDriverBuilder builder() {
141140
return RemoteWebDriver.builder().oneOf(new FirefoxOptions());
142141
}
143142

144-
private static FirefoxDriverCommandExecutor toExecutor(FirefoxOptions options) {
145-
Require.nonNull("Options to construct executor from", options);
146-
147-
FirefoxDriverService.Builder<?, ?> builder =
148-
StreamSupport.stream(ServiceLoader.load(DriverService.Builder.class).spliterator(), false)
149-
.filter(b -> b instanceof FirefoxDriverService.Builder)
150-
.map(FirefoxDriverService.Builder.class::cast)
151-
.findFirst().orElseThrow(WebDriverException::new);
152-
153-
return new FirefoxDriverCommandExecutor(builder.withOptions(options).build());
154-
}
155-
156143
/**
157144
* Check capabilities and proxy if it is set
158145
*/

0 commit comments

Comments
 (0)