File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed
java/client/src/org/openqa/selenium/remote Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,30 @@ public class RemoteWebDriverBuilder {
97
97
private final List <Capabilities > requestedCapabilities = new ArrayList <>();
98
98
private final Map <String , Object > additionalCapabilities = new TreeMap <>();
99
99
private final Map <String , Object > metadata = new TreeMap <>();
100
- private Function <ClientConfig , HttpHandler > handlerFactory = config -> HttpClient .Factory .createDefault ().createClient (config );
100
+ private Function <ClientConfig , HttpHandler > handlerFactory =
101
+ config -> {
102
+ HttpClient .Factory factory = HttpClient .Factory .createDefault ();
103
+ HttpClient client = factory .createClient (config );
104
+ return client .with (
105
+ next -> req -> {
106
+ try {
107
+ return client .execute (req );
108
+ } finally {
109
+ if (req .getMethod () == DELETE ) {
110
+ HttpSessionId .getSessionId (req .getUri ()).ifPresent (id -> {
111
+ if (("/session/" + id ).equals (req .getUri ())) {
112
+ try {
113
+ client .close ();
114
+ } catch (IOException e ) {
115
+ LOG .log (WARNING , "Swallowing exception while closing http client" , e );
116
+ }
117
+ factory .cleanupIdleClients ();
118
+ }
119
+ });
120
+ }
121
+ }
122
+ });
123
+ };
101
124
private ClientConfig clientConfig = ClientConfig .defaultConfig ();
102
125
private URI remoteHost = null ;
103
126
private DriverService driverService ;
You can’t perform that action at this time.
0 commit comments