Skip to content

JdkHttpSender leaks SelectorManager threadΒ #7388

@felixbarny

Description

@felixbarny

JdkHttpSender creates a java.net.http.HttpClient, which in turn creates an internal jdk.internal.net.http.HttpClientImpl.SelectorManager thread. When calling JdkHttpSender#shutdown, it doesn't terminate that thread.

The issue is that java.net.http.HttpClient#close has only been introduced in Java 21.

@jack-berg what do you think about adding a reflection-based check and call close when it's available?

I was thinking something like this:

    if (AutoCloseable.class.isInstance(client)) {
      try {
        AutoCloseable.class.cast(client).close();
      } catch (Exception e) {
        return CompletableResultCode.ofExceptionalFailure(e);
      }
    }

In JdkHttpSender#shutdown

@Override
public CompletableResultCode shutdown() {
if (managedExecutor) {
executorService.shutdown();
}
return CompletableResultCode.ofSuccess();
}

WDYT?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions