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


##########
platform/o.n.bootstrap/src/org/netbeans/ProxyClassLoader.java:
##########
@@ -468,34 +468,35 @@ protected Package getPackage(String name) {
      * @return located package, or null
      */
     protected Package getPackageFast(String name, boolean recurse) {
-        synchronized (packages) {
-            Package pkg = packages.get(name);
-            if (pkg != null) {
-                return pkg;
-            }
-            if (!recurse) {
-                return null;
-            }
-            String path = name.replace('.', '/');
-            for (ProxyClassLoader par : this.parents.loaders()) {
-                if (!shouldDelegateResource(path, par))
-                    continue;
-                pkg = par.getPackageFast(name, false);
-                if (pkg != null) break;
-            }
-            // pretend the resource ends with "/". This works better with 
hidden package and
-            // prefix-based checks.
-            if (pkg == null && shouldDelegateResource(path + "/", null)) {
-                // Cannot access either Package.getSystemPackages nor 
ClassLoader.getPackage
-                // from here, so do the best we can though it will cause 
unnecessary
-                // duplication of the package cache (PCL.packages vs. 
CL.packages):
-                pkg = super.getPackage(name);
+        Package pkg = packages.get(name);
+        if (pkg != null) {
+            return pkg;
+        }
+        if (!recurse) {
+            return null;
+        }
+        String path = name.replace('.', '/');
+        for (ProxyClassLoader par : this.parents.loaders()) {
+            if (!shouldDelegateResource(path, par)) {
+                continue;
             }
+            pkg = par.getPackageFast(name, false);
             if (pkg != null) {
-                packages.put(name, pkg);
+                break;
             }
-            return pkg;
         }
+        // pretend the resource ends with "/". This works better with hidden 
package and
+        // prefix-based checks.
+        if (pkg == null && shouldDelegateResource(path + "/", null)) {
+            // Cannot access either Package.getSystemPackages nor 
ClassLoader.getPackage
+            // from here, so do the best we can though it will cause 
unnecessary
+            // duplication of the package cache (PCL.packages vs. CL.packages):
+                pkg = super.getPackage(name);
+        }
+        if (pkg != null) {
+            packages.put(name, pkg);

Review Comment:
   You are correct, there can be a replaced entry in the map between the line 
471 and line 497. I will add again the `synchronized(packages)` block to 
prevent any nondeterministic result.



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