1
1
/*
2
- * Copyright (c) 2015, 2024 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2015, 2025 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
38
38
import javax .net .ssl .SSLContext ;
39
39
import javax .net .ssl .SSLParameters ;
40
40
import javax .net .ssl .SSLServerSocket ;
41
+
41
42
import jdk .internal .net .http .frame .ErrorFrame ;
42
43
43
44
/**
@@ -64,24 +65,18 @@ public class Http2TestServer implements AutoCloseable {
64
65
// request approver which takes the server connection key as the input
65
66
private volatile Predicate <String > newRequestApprover ;
66
67
67
- private static ThreadFactory defaultThreadFac =
68
- (Runnable r ) -> {
69
- Thread t = new Thread (r );
70
- t .setName ("Test-server-pool" );
71
- return t ;
72
- };
73
-
74
-
75
- private static ExecutorService getDefaultExecutor () {
76
- return Executors .newCachedThreadPool (defaultThreadFac );
68
+ private static ExecutorService createExecutor (String name ) {
69
+ String threadNamePrefix = "%s-pool" .formatted (name );
70
+ ThreadFactory threadFactory = Thread .ofPlatform ().name (threadNamePrefix , 0 ).factory ();
71
+ return Executors .newCachedThreadPool (threadFactory );
77
72
}
78
73
79
74
public Http2TestServer (String serverName , boolean secure , int port ) throws Exception {
80
- this (serverName , secure , port , getDefaultExecutor () , 50 , null , null );
75
+ this (serverName , secure , port , null , 50 , null , null );
81
76
}
82
77
83
78
public Http2TestServer (boolean secure , int port ) throws Exception {
84
- this (null , secure , port , getDefaultExecutor () , 50 , null , null );
79
+ this (null , secure , port , null , 50 , null , null );
85
80
}
86
81
87
82
public InetSocketAddress getAddress () {
@@ -197,7 +192,7 @@ public Http2TestServer(InetAddress localAddr,
197
192
server = initPlaintext (port , backlog );
198
193
}
199
194
this .secure = secure ;
200
- this .exec = exec == null ? getDefaultExecutor ( ) : exec ;
195
+ this .exec = exec == null ? createExecutor ( name ) : exec ;
201
196
this .handlers = Collections .synchronizedMap (new HashMap <>());
202
197
this .properties = properties == null ? new Properties () : properties ;
203
198
this .connections = ConcurrentHashMap .newKeySet ();
0 commit comments