RFR: 8273874: LdapClient can trigger memory leak
Jaikiran Pai
jpai at openjdk.org
Thu Feb 26 10:31:02 UTC 2026
Can I please get a review of this change which addresses an issue in the `java.naming` module?
As noted in https://bugs.openjdk.org/browse/JDK-8273874 when a `javax.naming.Context` is constructed backed by a `com.sun.jndi.ldap.LdapCtxFactory`, the internal implemenation of `LdapCtx` can lead to creation of Threads that are used for the managing connections and for managing event notifications. These threads are system threads. However, the way they are created currently, they end up capturing the context classloader of the calling Thread. This classloader will be held onto as long as these Threads stay alive and can thus prevent the classloader from being unreferenced.
The change in this PR replaces the creation of these threads with the `InnocuousThread`s, which do not have a context classloader associated with them.
A new jtreg test has been introduced to reproduce the issue and verify the fix. Existing tests continue to pass with this change.
-------------
Commit messages:
- add test
- 8273874: LdapClient can trigger memory leak
Changes: https://git.openjdk.org/jdk/pull/29934/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29934&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8273874
Stats: 341 lines in 4 files changed: 330 ins; 5 del; 6 mod
Patch: https://git.openjdk.org/jdk/pull/29934.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/29934/head:pull/29934
PR: https://git.openjdk.org/jdk/pull/29934
More information about the core-libs-dev
mailing list