-
Notifications
You must be signed in to change notification settings - Fork 324
Closed
Description
Here is a simple program that tracks the number of reactor http nio threads before and after callingdispose(), and the results as I run it. The thread count doesn't go back to 0 after calling dispose(). I'm using 2.19.0.RELEASE.
Program:
public static void main(String[] args) throws InterruptedException {
trackThreads("reactor-http-nio");
}
private static void trackThreads(final String threadPrefix) throws InterruptedException {
System.out.println(threadPrefix + " THREAD COUNT");
System.out.println(" (start) " + getThreadCount(threadPrefix));
final DefaultConnectionContext connectionContext = DefaultConnectionContext.builder()
.apiHost("api.run.pivotal.io")
.build();
System.out.println(" (after build) " + getThreadCount(threadPrefix));
connectionContext.dispose();
System.out.println(" (after dispose) " + getThreadCount(threadPrefix));
Thread.sleep(10000);
System.out.println(" (after 10 seconds) " + getThreadCount(threadPrefix));
}
private static long getThreadCount(final String threadPrefix) {
return Thread.getAllStackTraces().keySet().stream()
.filter(thread -> thread.getName().startsWith(threadPrefix)).count();
}
Result:
reactor-http-nio THREAD COUNT
(start) 0
(after build) 8
(after dispose) 8
(after 10 seconds) 8