pepness commented on code in PR #6596:
URL: https://github.com/apache/netbeans/pull/6596#discussion_r1375147938
##########
enterprise/glassfish.common/src/org/netbeans/modules/glassfish/common/GlassfishInstance.java:
##########
@@ -180,7 +182,7 @@ public boolean containsValue(Object value) {
@Override
public boolean containsKey(Object key) {
- synchronized(delegate) {return delegate.containsKey(key);}
+ return delegate.computeIfPresent((String) key, (k, v) -> v) !=
null;
}
Review Comment:
I agree that just `containsKey` will suffice.
> (not to mention that you check for the value not being null, which is not
always the same as checking if the key is present)
I checked the source code and find that the `containsKey` implementation of
CHM is `get(key) != null` which checks for the value and the implementation for
normal HM is `getNode(key) != null` which checks for the Node. This implies
that the new code will work correctly for a CHM but not necessary for a HM, I
have learned something new, thanks @mbien.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists