Skip to content

Commit

Permalink
[cdp] Handle the case where the original endpoint is unreachable
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Sep 28, 2021
1 parent 31cb246 commit e8e1bc4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion java/src/org/openqa/selenium/devtools/CdpEndpointFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.openqa.selenium.remote.http.HttpRequest;
import org.openqa.selenium.remote.http.HttpResponse;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;
Expand All @@ -48,7 +50,13 @@ public static Optional<URI> getCdpEndPoint(HttpClient.Factory clientFactory, URI
ClientConfig config = ClientConfig.defaultConfig().baseUri(reportedUri);
HttpClient client = clientFactory.createClient(config);

HttpResponse res = client.execute(new HttpRequest(GET, "/json/version"));
HttpResponse res;
try {
res = client.execute(new HttpRequest(GET, "/json/version"));
} catch (UncheckedIOException e) {
LOG.warning("Unable to connect to determine websocket url: " + e.getMessage());
return Optional.empty();
}
if (res.getStatus() != HTTP_OK) {
return Optional.empty();
}
Expand Down

0 comments on commit e8e1bc4

Please sign in to comment.