Skip to content

WebClient using default reactor-netty client leaks netty ByteBufs on timeout #22384

@danielra

Description

@danielra

Affects: 5.1.4.RELEASE

I see buffer leak reports from Netty's ResourceLeakDetector when a Mono.timeout cancels a subscription to the Mono returned from bodyToMono. I've created a demo project with a test case which seems to reliably reproduce the issue. A separate test case is included which uses the reactor-netty HttpClient directly instead of using it through the WebClient wrapper - and I have not seen any leak reports in this case with the current version of reactor-netty (v0.8.4.RELEASE).

Demo project with mentioned test cases can be found here:
https://github.com/danielra/buffer-leak-repro-reactor-netty
The specific test case which reproduces the leak can be seen here:
https://github.com/danielra/buffer-leak-repro-reactor-netty/blob/master/src/test/java/com/example/demo/DemoApplicationTests.java#L59

The tests can be run via ./gradlew clean test --debug. Please note that the tests "pass" unconditionally, but buffer leak reports can be viewed in the console output.

Here is an example of the leak report log messages I have observed from this test case:
webclient_buffer_leak_example_log.txt


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