Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Generic Name for SimplePool Connection Threads (1.6.x) #2090

Merged
merged 1 commit into from
Apr 10, 2024
Merged
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 @@ -69,8 +69,8 @@ public SimpleConnection makeConnection(
final Set<SimpleConnection> allCreatedConnections) throws RuntimeException
{
boolean isHttps = uri.getScheme().equalsIgnoreCase("https");
XnioWorker worker = getWorker(isHttp2);
XnioSsl ssl = getSSL(isHttps, isHttp2);
XnioWorker worker = getWorker();
XnioSsl ssl = getSSL(isHttps);
OptionMap connectionOptions = getConnectionOptions(isHttp2);
InetSocketAddress bindAddress = null;

Expand Down Expand Up @@ -138,10 +138,9 @@ private static OptionMap getConnectionOptions(boolean isHttp2) {
* WARNING: This is called by getSSL(). Therefore, this method must never
* call getSSL(), or any method that transitively calls getSSL()
*
* @param isHttp2 if true, sets worker thread names to show HTTP2
* @return new XnioWorker
*/
private static XnioWorker getWorker(boolean isHttp2)
private static XnioWorker getWorker()
{
if(WORKER.get() != null) return WORKER.get();

Expand All @@ -151,7 +150,7 @@ private static XnioWorker getWorker(boolean isHttp2)

Xnio xnio = Xnio.getInstance(Undertow.class.getClassLoader());
try {
WORKER.set(xnio.createWorker(null, getWorkerOptionMap(isHttp2)));
WORKER.set(xnio.createWorker(null, getWorkerOptionMap()));
} catch (IOException e) {
logger.error("Exception while creating new XnioWorker", e);
throw new RuntimeException(e);
Expand All @@ -160,13 +159,13 @@ private static XnioWorker getWorker(boolean isHttp2)
return WORKER.get();
}

private static OptionMap getWorkerOptionMap(boolean isHttp2)
private static OptionMap getWorkerOptionMap()
{
OptionMap.Builder optionBuild = OptionMap.builder()
.set(Options.WORKER_IO_THREADS, 8)
.set(Options.TCP_NODELAY, true)
.set(Options.KEEP_ALIVE, true)
.set(Options.WORKER_NAME, isHttp2 ? "Callback-HTTP2" : "Callback-HTTP11");
.set(Options.WORKER_NAME, "simplepool");
return optionBuild.getMap();
}

Expand All @@ -176,10 +175,9 @@ private static OptionMap getWorkerOptionMap(boolean isHttp2)
* WARNING: This calls getWorker()
*
* @param isHttps true if this is an HTTPS connection
* @param isHttp2 if true, sets worker thread names to show HTTP2
* @return new XnioSSL
*/
private static XnioSsl getSSL(boolean isHttps, boolean isHttp2)
private static XnioSsl getSSL(boolean isHttps)
{
if(!isHttps) return null;
if(SSL.get() != null) return SSL.get();
Expand All @@ -189,7 +187,7 @@ private static XnioSsl getSSL(boolean isHttps, boolean isHttp2)
if(SSL.get() != null) return SSL.get();

try {
SSL.set(new UndertowXnioSsl(getWorker(isHttp2).getXnio(), OptionMap.EMPTY, BUFFER_POOL, SimpleSSLContextMaker.createSSLContext()));
SSL.set(new UndertowXnioSsl(getWorker().getXnio(), OptionMap.EMPTY, BUFFER_POOL, SimpleSSLContextMaker.createSSLContext()));
} catch (Exception e) {
logger.error("Exception while creating new shared UndertowXnioSsl used to create connections", e);
throw new RuntimeException(e);
Expand Down