Skip to content

DefaultConnectionContext.dispose() does not destroy reactor-http-nio threads #816

@chlam4

Description

@chlam4

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions