Skip to content

SubmissionPublisher virtual-thread executors are never closed #28

@nficano

Description

@nficano

Several classes create a new virtual-thread ExecutorService inline for SubmissionPublisher and do not keep a reference to close it. Examples include ReplayingPublisher at arcp-client/src/main/java/dev/arcp/client/ReplayingPublisher.java line 25, ArcpClient.subscribe at arcp-client/src/main/java/dev/arcp/client/ArcpClient.java line 173, MemoryTransport at arcp-core/src/main/java/dev/arcp/core/transport/MemoryTransport.java lines 26 and 27, StdioTransport at arcp-core/src/main/java/dev/arcp/core/transport/StdioTransport.java line 67, WebSocketTransport at arcp-client/src/main/java/dev/arcp/client/WebSocketTransport.java line 42, and the Jakarta, Spring, Vert.x, and Jetty WebSocket transport adapters. Closing a SubmissionPublisher does not give the caller a way to shut down an anonymous executor service, so repeated transports and subscriptions can leave executor resources unmanaged.

Fix prompt: Introduce an owned executor field wherever the SDK creates a SubmissionPublisher with Executors.newVirtualThreadPerTaskExecutor(), pass that field into the publisher, and shut it down or close it in the same close path that closes the publisher. Where many publishers are expected, prefer a shared executor owned by the parent client, runtime, or transport adapter, with clear ownership and lifecycle. Add tests or leak checks that create and close transports and subscriptions repeatedly and verify the owned executors are closed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance and resource-efficiency workseverity:mediumMedium severity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions