RFR: 8344246: Unnecessary Hashtable usage in EventSupport.notifiers
Andrey Turbanov
aturbanov at openjdk.org
Mon Dec 9 07:12:45 UTC 2024
On Tue, 5 Nov 2024 08:28:10 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:
> 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`.
Let's review it
-------------
PR Comment: https://git.openjdk.org/jdk/pull/21894#issuecomment-2527111932
More information about the core-libs-dev
mailing list