17
17
18
18
package org .openqa .selenium .grid .router ;
19
19
20
+ import static org .openqa .selenium .remote .HttpSessionId .getSessionId ;
21
+ import static org .openqa .selenium .remote .RemoteTags .SESSION_ID ;
22
+ import static org .openqa .selenium .remote .RemoteTags .SESSION_ID_EVENT ;
23
+ import static org .openqa .selenium .remote .http .Contents .asJson ;
24
+ import static org .openqa .selenium .remote .tracing .Tags .EXCEPTION ;
25
+ import static org .openqa .selenium .remote .tracing .Tags .HTTP_REQUEST ;
26
+ import static org .openqa .selenium .remote .tracing .Tags .HTTP_REQUEST_EVENT ;
27
+ import static org .openqa .selenium .remote .tracing .Tags .HTTP_RESPONSE ;
28
+
20
29
import com .google .common .cache .Cache ;
21
30
import com .google .common .cache .CacheBuilder ;
22
31
import com .google .common .cache .RemovalListener ;
23
32
import com .google .common .collect .ImmutableMap ;
24
33
25
34
import org .openqa .selenium .NoSuchSessionException ;
26
- import org .openqa .selenium .concurrent .Regularly ;
27
35
import org .openqa .selenium .grid .data .Session ;
28
36
import org .openqa .selenium .grid .sessionmap .SessionMap ;
29
37
import org .openqa .selenium .grid .web .ReverseProxyHandler ;
47
55
import java .util .HashMap ;
48
56
import java .util .Map ;
49
57
import java .util .concurrent .Callable ;
50
-
51
- import static org .openqa .selenium .remote .HttpSessionId .getSessionId ;
52
- import static org .openqa .selenium .remote .RemoteTags .SESSION_ID ;
53
- import static org .openqa .selenium .remote .RemoteTags .SESSION_ID_EVENT ;
54
- import static org .openqa .selenium .remote .http .Contents .asJson ;
55
- import static org .openqa .selenium .remote .tracing .Tags .EXCEPTION ;
56
- import static org .openqa .selenium .remote .tracing .Tags .HTTP_REQUEST ;
57
- import static org .openqa .selenium .remote .tracing .Tags .HTTP_REQUEST_EVENT ;
58
- import static org .openqa .selenium .remote .tracing .Tags .HTTP_RESPONSE ;
58
+ import java .util .concurrent .Executors ;
59
+ import java .util .concurrent .ScheduledExecutorService ;
60
+ import java .util .concurrent .TimeUnit ;
59
61
60
62
class HandleSession implements HttpHandler {
61
63
@@ -77,8 +79,16 @@ class HandleSession implements HttpHandler {
77
79
.removalListener ((RemovalListener <URL , HttpClient >) removal -> removal .getValue ().close ())
78
80
.build ();
79
81
80
- new Regularly ("Clean up http clients cache" ).submit (
81
- httpClients ::cleanUp , Duration .ofMinutes (1 ), Duration .ofMinutes (1 ));
82
+ ScheduledExecutorService cleanUpHttpClientsCacheService =
83
+ Executors .newSingleThreadScheduledExecutor (
84
+ r -> {
85
+ Thread thread = new Thread (r );
86
+ thread .setDaemon (true );
87
+ thread .setName ("HandleSession - Clean up http clients cache" );
88
+ return thread ;
89
+ });
90
+ cleanUpHttpClientsCacheService .scheduleAtFixedRate (
91
+ httpClients ::cleanUp , 1 , 1 , TimeUnit .MINUTES );
82
92
}
83
93
84
94
@ Override
0 commit comments