Integrated: 8277954: Replace use of monitors with explicit locks in the JDK LDAP provider implementation
Aleksei Efimov
aefimov at openjdk.org
Mon Sep 11 14:08:45 UTC 2023
On Thu, 31 Aug 2023 22:48:30 GMT, Aleksei Efimov <aefimov at openjdk.org> wrote:
> The change proposed in this PR improves the behavior of the JDK JNDI/LDAP provider when running in a virtual thread. Currently, when an LDAP operation is performed from a virtual thread context a pinned carrier thread is detected:
>
> Thread[#29,ForkJoinPool-1-worker-1,5,CarrierThreads]
> java.naming/com.sun.jndi.ldap.Connection.read reply(Connection.java:444) <== monitors:1
> java.naming/com.sun.jndi.ldap.LdapClient.ldapBind(LdapClient.java:369) <== monitors:1
> java.naming/com.sun.jndi.ldap.LdapClient.authenticate(LdapClient.java:196) <== monitors:1
> java.naming/com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2896) <== monitors:1
>
> To fix that monitor usages are replaced with `j.u.c` locks. All synchronized blocks/methods have been replaced with locks even if it is only guarding memory access - the motivation behind such a decision was to avoid an analysis of scenarios where a mix of monitors and `j.u.c` locks is used.
>
> There are three types of mechanical changes done in this PR:
>
> 1. Classes with `synchronized` blocks or `synchronized` methods have been updated to include a new `ReentrantLock` field. These new fields are used to replace `synchronized` blocks/methods.
> 1. classes that use notify/wait on object monitor have been updated to use `ReentrantLock.Condition`s signal/await.
> 1. if one class `synchronized` on an instance of another class - the `ReentrantLock` added in item (1) was made a package-protected to give access to another class.
>
> With the proposed changes pinned carrier threads are no longer detected during execution of LDAP operations.
>
> Testing: `jdk-tier1` to `jdk-tier3`, other `jndi/ldap` regression and JCK naming tests show no failures.
This pull request has now been integrated.
Changeset: 66b6a5a8
Author: Aleksei Efimov <aefimov at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/66b6a5a84f13157c8b02cf64f86c064517cd4710
Stats: 970 lines in 11 files changed: 394 ins; 101 del; 475 mod
8277954: Replace use of monitors with explicit locks in the JDK LDAP provider implementation
Reviewed-by: dfuchs
-------------
PR: https://git.openjdk.org/jdk/pull/15526
More information about the core-libs-dev
mailing list