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


##########
platform/o.n.bootstrap/src/org/netbeans/ProxyClassLoader.java:
##########
@@ -468,28 +468,31 @@ protected Package getPackage(String name) {
      * @return located package, or null
      */
     protected Package getPackageFast(String name, boolean recurse) {
-        synchronized (packages) {
+        if (!recurse) {
+            return null;
+        }
+        synchronized(packages) {
             Package pkg = packages.get(name);
             if (pkg != null) {
                 return pkg;
             }
-            if (!recurse) {
-                return null;
-            }

Review Comment:
   this alters the behavior. The recursive check has to be after the first 
`get` and `return`.
   
   I think you could do this however:
   
   ```java
           Package pkg = packages.get(name);
           if (pkg != null) {
               return pkg;
           }
           if (!recurse) {
               return null;
           }
           synchronized(packages) {
               pkg = packages.get(name);
               ...
           
   ```
   essentially calling `get` twice, with a lock free path for the non-recursive 
case



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