Skip to content

Add netty leak detection extension#1291

Merged
sdelamo merged 6 commits into4.10.xfrom
leak-detection
Oct 20, 2025
Merged

Add netty leak detection extension#1291
sdelamo merged 6 commits into4.10.xfrom
leak-detection

Conversation

@yawkat
Copy link
Member

@yawkat yawkat commented Oct 17, 2025

The new netty LeakPresenceDetector allows for leak detection that is more lightweight, faster, and more reliable. Add a micronaut-test module that enables leak detection through a jupiter and a spock extension.

The new netty LeakPresenceDetector allows for leak detection that is more lightweight, faster, and more reliable. Add a micronaut-test module that enables leak detection through a jupiter and a spock extension.
@yawkat yawkat requested review from graemerocher and melix October 17, 2025 12:44
@yawkat yawkat added the type: enhancement New feature or request label Oct 17, 2025
yawkat added a commit to micronaut-projects/micronaut-core that referenced this pull request Oct 17, 2025
Netty 4.2.7 introduced a new leak detection mechanism for tests that is more reliable and has lower overhead. micronaut-projects/micronaut-test#1291 introduces a micronaut-test module that uses this new mechanism. However, the new detector is more strict about resource lifetimes, so tests need various small adjustments:

- Contexts must be closed at the end of the test
- Event loops must be shut down
- Tests must use only threads created in those tests (no Finalizers, no reactive boundedElastic)
- SSL contexts must be released immediately

There is also one minor leak fix in this PR, related to h2c support, in Http2ServerHandler.

Draft because this requires the new micronaut-test module.
@sdelamo sdelamo moved this to In Progress in 4.10.0 Release Oct 17, 2025
@graemerocher graemerocher requested review from melix and sdelamo October 17, 2025 15:44
@sdelamo sdelamo changed the base branch from 4.9.x to 4.10.x October 17, 2025 15:57
@sonarqubecloud
Copy link

@yawkat
Copy link
Member Author

yawkat commented Oct 17, 2025

The remaining CI failures look unrelated, I think this can be safely merged @sdelamo

@sdelamo sdelamo merged commit 9dd78b3 into 4.10.x Oct 20, 2025
10 of 13 checks passed
@sdelamo sdelamo deleted the leak-detection branch October 20, 2025 03:34
@github-project-automation github-project-automation bot moved this from In Progress to Done in 4.10.0 Release Oct 20, 2025
@radovanradic
Copy link

The remaining CI failures look unrelated, I think this can be safely merged @sdelamo

Btw, I am seeing this error all over

java.lang.NullPointerException: Cannot invoke "jdk.internal.platform.CgroupInfo.getMountPoint()" because "anyController" is null

when test-resources are used in 4.x branches. Seem to work fine in branches for Micronaut 5.x

yawkat added a commit to micronaut-projects/micronaut-core that referenced this pull request Dec 15, 2025
* New leak detection for tests
Netty 4.2.7 introduced a new leak detection mechanism for tests that is more reliable and has lower overhead. micronaut-projects/micronaut-test#1291 introduces a micronaut-test module that uses this new mechanism. However, the new detector is more strict about resource lifetimes, so tests need various small adjustments:

- Contexts must be closed at the end of the test
- Event loops must be shut down
- Tests must use only threads created in those tests (no Finalizers, no reactive boundedElastic)
- SSL contexts must be released immediately

There is also one minor leak fix in this PR, related to h2c support, in Http2ServerHandler.

Draft because this requires the new micronaut-test module.

* move to micronaut-test module

* fix test

* Update gradle/libs.versions.toml

Co-authored-by: Sergio del Amo <sergio.delamo@softamo.com>

* enable trackCreationStack

* disable trackCreationStack

---------

Co-authored-by: Sergio del Amo <sergio.delamo@softamo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement New feature or request

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants