You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by sd...@apache.org on 2021/09/13 21:24:16 UTC

[netbeans] branch master updated: Return a copy instead of cached array

This is an automated email from the ASF dual-hosted git repository.

sdedic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 3fc65de  Return a copy instead of cached array
     new 60d04ff  Merge pull request #3163 from sdedic/bugfix/classpath-copy
3fc65de is described below

commit 3fc65de9579d6e81da8a6ddf6de2d4939347e3f8
Author: Svata Dedic <sv...@oracle.com>
AuthorDate: Sun Sep 12 10:13:44 2021 +0200

    Return a copy instead of cached array
---
 .../src/org/netbeans/api/java/classpath/ClassPath.java              | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/ide/api.java.classpath/src/org/netbeans/api/java/classpath/ClassPath.java b/ide/api.java.classpath/src/org/netbeans/api/java/classpath/ClassPath.java
index 83364f6..9842730 100644
--- a/ide/api.java.classpath/src/org/netbeans/api/java/classpath/ClassPath.java
+++ b/ide/api.java.classpath/src/org/netbeans/api/java/classpath/ClassPath.java
@@ -241,7 +241,7 @@ public final class ClassPath {
         long current;
         synchronized (this) {
             if (rootsCache != null) {
-                return this.rootsCache;
+                return rootsCache.clone();
             }
             current = this.invalidRoots;
         }
@@ -256,9 +256,9 @@ public final class ClassPath {
                 if (rootsCache == null || rootsListener == null) {
                     attachRootsListener();
                     listenOnRoots(rootPairs);
-                    this.rootsCache = roots;
+                    this.rootsCache = roots.clone();
                 } else {
-                    roots = this.rootsCache;
+                    roots = rootsCache.clone();
                 }
             }
         }

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

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