mbien commented on code in PR #6596:
URL: https://github.com/apache/netbeans/pull/6596#discussion_r1371989050


##########
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:
   but a CHM does not require synchronization there. It simply answers the 
question: is the key in that map/set.
   
   regular collections do have to be synchronized when using getters since 
there are no guarantees that a thread would ever see a result.
   
   `containsKey` is perfectly fine here IMO.
   
   (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)



-- 
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

Reply via email to