RFR: 8344246: Unnecessary Hashtable usage in EventSupport.notifiers
Andrey Turbanov
aturbanov at openjdk.org
Thu Nov 14 19:41:47 UTC 2024
The field `com.sun.jndi.ldap.EventSupport#notifiers` is always accessed under `lock`. It means extra synchronization from `Hashtable` is not needed.
Subtle difference in Hashtable vs Hashmap behavior is that Hashtable doesn't allow `null` keys and `null` values. I've checked all usages of it - only non-null keys and values are put into it. So, replacement is safe.
One thing which was suspicous for me is `null` check of value in the `com.sun.jndi.ldap.EventSupport#removeNamingListener` method:
https://github.com/openjdk/jdk/blob/b54bd824b59b6b5dff9278ddebab4e9e2dfaf57b/src/java.naming/share/classes/com/sun/jndi/ldap/EventSupport.java#L230-L235
The condition `notifier != null` is always `true`.
-------------
Commit messages:
- [PATCH] Unnecessary Hashtable usage in EventSupport.notifiers
Changes: https://git.openjdk.org/jdk/pull/21894/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21894&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8344246
Stats: 5 lines in 1 file changed: 0 ins; 1 del; 4 mod
Patch: https://git.openjdk.org/jdk/pull/21894.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/21894/head:pull/21894
PR: https://git.openjdk.org/jdk/pull/21894
More information about the core-libs-dev
mailing list