Skip to content

Memory leak in RpcClient #1168

Closed
Closed
@JHahnHRO

Description

@JHahnHRO

Describe the bug

RpcClient must be given a Channel upon construction and if used in mandatory-mode, the constructor adds a ReturnListener to this channel. However, this listener is never removed. It should be removed in the close-method.

Reproduction steps

  1. Instantiate RpcClient in mandatory-mode.
  2. Publish an unrouteable RPC message with the client and catch the UnrouteableRpcRequestException.
  3. Close the RpcClient.
  4. Repeat 1.-3. using the same channel.

Observe that first there will be an exception, then there will be an exception and a log-warning, then an exception and two log-warnings, then an exception and three log-warnings and so on. The reason is that each new RpcClient adds its own ReturnListener. One of them throws the exception, the other log warnings, because they look up the returned message in the previous RpcClient's continuation maps.

The log messages are annoying, but more importantly, the listeners accumulate over time and live for as long as the channel stays open.

Expected behavior

Closing an RpcClient should clean up thoroughly, including the removal of the ReturnListener so that the channel may be reused.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions