Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion java/src/org/openqa/selenium/devtools/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

import java.io.Closeable;
import java.io.StringReader;
import java.net.URI;
import java.net.URISyntaxException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -51,6 +53,7 @@
import org.openqa.selenium.json.Json;
import org.openqa.selenium.json.JsonInput;
import org.openqa.selenium.json.JsonOutput;
import org.openqa.selenium.remote.http.ClientConfig;
import org.openqa.selenium.remote.http.HttpClient;
import org.openqa.selenium.remote.http.HttpRequest;
import org.openqa.selenium.remote.http.WebSocket;
Expand All @@ -72,7 +75,7 @@ public class Connection implements Closeable {
new ConcurrentHashMap<>();
private final ReadWriteLock callbacksLock = new ReentrantReadWriteLock(true);
private final Map<Event<?>, List<Consumer<?>>> eventCallbacks = new HashMap<>();
private final HttpClient client;
private HttpClient client;
private final String url;
private final AtomicBoolean isClosed;

Expand All @@ -90,6 +93,14 @@ boolean isClosed() {
}

void reopen() {
HttpClient.Factory clientFactory = HttpClient.Factory.createDefault();
ClientConfig wsConfig = null;
try {
wsConfig = ClientConfig.defaultConfig().baseUri(new URI(this.url));
} catch (URISyntaxException e) {
LOG.warning(e.getMessage());
}
this.client = clientFactory.createClient(wsConfig);
this.socket = this.client.openSocket(new HttpRequest(GET, url), new Listener());
}

Expand Down
2 changes: 0 additions & 2 deletions java/test/org/openqa/selenium/devtools/DevToolsReuseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.Augmenter;

class DevToolsReuseTest extends DevToolsTestBase {

@Test
@Disabled("JDK HTTP Client cannot get reused")
public void shouldBeAbleToCloseDevToolsAndCreateNewInstance() {
WebDriver driver = new Augmenter().augment(this.driver);

Expand Down