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
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@
import org.openqa.selenium.remote.Dialect;
import org.openqa.selenium.remote.SessionId;
import org.openqa.selenium.remote.http.HttpClient;
import org.openqa.selenium.remote.http.HttpHandler;
import org.openqa.selenium.remote.http.HttpRequest;
import org.openqa.selenium.remote.http.HttpResponse;
import org.openqa.selenium.remote.tracing.Tracer;

public class DefaultActiveSession extends BaseActiveSession {

private final HttpHandler handler;
private final ReverseProxyHandler handler;
private final String killUrl;

protected DefaultActiveSession(
Expand Down Expand Up @@ -68,6 +67,6 @@ public HttpResponse execute(HttpRequest req) throws UncheckedIOException {

@Override
public void stop() {
// no-op
handler.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ public Either<WebDriverException, ActiveSession> apply(CreateSessionRequest sess
caps = readPrefixedCaps(capabilities, caps);

span.addEvent("Driver service created session", attributeMap);
final HttpClient fClient = client;
return Either.right(
new DefaultActiveSession(
tracer,
Expand All @@ -204,9 +203,8 @@ public Either<WebDriverException, ActiveSession> apply(CreateSessionRequest sess
Instant.now()) {
@Override
public void stop() {
try (fClient) {
service.stop();
}
super.stop();
service.stop();
}
});
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public void stop() {
}
saveLogs();
container.stop(Duration.ofMinutes(1));
super.stop();
}

private void saveLogs() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public UsageCountingReverseProxyHandler(

@Override
public void close() {
// must not call super.close() here, to ensure the HttpClient stays alive
// set the last use here, to ensure we have to calculate the real inactivity of the client
entry.lastUse = Instant.now();
entry.inUse.decrementAndGet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.openqa.selenium.remote.tracing.Span;
import org.openqa.selenium.remote.tracing.Tracer;

public class ReverseProxyHandler implements HttpHandler {
public class ReverseProxyHandler implements HttpHandler, AutoCloseable {

private static final Logger LOG = Logger.getLogger(ReverseProxyHandler.class.getName());

Expand Down Expand Up @@ -101,4 +101,9 @@ public HttpResponse execute(HttpRequest req) throws UncheckedIOException {
return resp;
}
}

@Override
public void close() {
upstream.close();
}
}
Loading