You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2021/09/12 08:17:03 UTC

[GitHub] [netbeans] sdedic opened a new pull request #3163: Return a copy instead of cached array

sdedic opened a new pull request #3163:
URL: https://github.com/apache/netbeans/pull/3163


   During some implementation I've mindlessly modified the result of `ClassPath.getRoots()` call ... and then spent more than 5 hours by hunting down the bug since it wasn't originally obvious, but "sometimes" the parser stopped to resolving symbols against the classpath. "sometimes" = when the added (debugging) code run and modified the ClassPath caches for all IDE.
   I think making the code fool-proof is worth the array-copy overhead...


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #3163: Return a copy instead of cached array

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3163:
URL: https://github.com/apache/netbeans/pull/3163#discussion_r707027841



##########
File path: ide/api.java.classpath/src/org/netbeans/api/java/classpath/ClassPath.java
##########
@@ -241,7 +241,7 @@ public ClassPathImplementation getClassPathImpl(ClassPath cp) {
         long current;
         synchronized (this) {
             if (rootsCache != null) {
-                return this.rootsCache;
+                return Arrays.copyOf(rootsCache, rootsCache.length);

Review comment:
       I'd use `this.rootsCache.clone()`.




-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sdedic merged pull request #3163: Return a copy instead of cached array

Posted by GitBox <gi...@apache.org>.
sdedic merged pull request #3163:
URL: https://github.com/apache/netbeans/pull/3163


   


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sdedic commented on a change in pull request #3163: Return a copy instead of cached array

Posted by GitBox <gi...@apache.org>.
sdedic commented on a change in pull request #3163:
URL: https://github.com/apache/netbeans/pull/3163#discussion_r707050420



##########
File path: ide/api.java.classpath/src/org/netbeans/api/java/classpath/ClassPath.java
##########
@@ -241,7 +241,7 @@ public ClassPathImplementation getClassPathImpl(ClassPath cp) {
         long current;
         synchronized (this) {
             if (rootsCache != null) {
-                return this.rootsCache;
+                return Arrays.copyOf(rootsCache, rootsCache.length);

Review comment:
       Good point; recommitted as 3fc65de. Thanks.




-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists