Remove dependency on implementation of http client factory from the factory
import org.openqa.selenium.BuildInfo;
import org.openqa.selenium.Platform;
-import org.openqa.selenium.remote.internal.OkHttpClient;
import java.io.IOException;
import java.net.Proxy;
import java.net.URL;
import java.time.Duration;
-import java.util.Objects;
import java.util.Locale;
+import java.util.Objects;
/**
* Defines a simple client for making HTTP requests.
@@ -63,7 +62,14 @@ static Factory createDefault() {
switch (defaultFactory) {
case "okhttp":
default:
- return new OkHttpClient.Factory();
+ try {
+ Class<? extends Factory> clazz =
+ Class.forName("org.openqa.selenium.remote.internal.OkHttpClient$Factory")
+ .asSubclass(Factory.class);
+ return clazz.newInstance();
+ } catch (ReflectiveOperationException e) {
+ throw new UnsupportedOperationException("Unable to create HTTP client factory", e);
+ }
}
}
