ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1234276 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/DirectoryScanner.java
Date Sat, 21 Jan 2012 07:05:16 GMT
Author: bodewig
Date: Sat Jan 21 07:05:15 2012
New Revision: 1234276

URL: http://svn.apache.org/viewvc?rev=1234276&view=rev
Log:
synchronize access to default excludes.  PR 52188.

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1234276&r1=1234275&r2=1234276&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Sat Jan 21 07:05:15 2012
@@ -119,6 +119,9 @@ Fixed bugs:
  * ZipFile didn't work properly for archives using unicode extra
    fields rather than UTF-8 filenames and the EFS-Flag.
 
+ * Access to DirectoryScanner's default excludes wasn't synchronized.
+   BigZilla Report 52188.
+
 Other changes:
 --------------
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java?rev=1234276&r1=1234275&r2=1234276&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java Sat Jan 21 07:05:15
2012
@@ -216,7 +216,7 @@ public class DirectoryScanner
      *
      * @see #addDefaultExcludes()
      */
-    private static Set defaultExcludes = new HashSet();
+    private static final Set defaultExcludes = new HashSet();
     static {
         resetDefaultExcludes();
     }
@@ -557,8 +557,10 @@ public class DirectoryScanner
      * @since Ant 1.6
      */
     public static String[] getDefaultExcludes() {
+        synchronized (defaultExcludes) {
         return (String[]) defaultExcludes.toArray(new String[defaultExcludes
                                                              .size()]);
+        }
     }
 
     /**
@@ -572,7 +574,9 @@ public class DirectoryScanner
      * @since Ant 1.6
      */
     public static boolean addDefaultExclude(String s) {
+        synchronized (defaultExcludes) {
         return defaultExcludes.add(s);
+        }
     }
 
     /**
@@ -587,7 +591,9 @@ public class DirectoryScanner
      * @since Ant 1.6
      */
     public static boolean removeDefaultExclude(String s) {
+        synchronized (defaultExcludes) {
         return defaultExcludes.remove(s);
+        }
     }
 
     /**
@@ -596,10 +602,12 @@ public class DirectoryScanner
      * @since Ant 1.6
      */
     public static void resetDefaultExcludes() {
-        defaultExcludes = new HashSet();
+        synchronized (defaultExcludes) {
+            defaultExcludes.clear();
         for (int i = 0; i < DEFAULTEXCLUDES.length; i++) {
             defaultExcludes.add(DEFAULTEXCLUDES[i]);
         }
+        }
     }
 
     /**
@@ -1739,11 +1747,11 @@ public class DirectoryScanner
     public synchronized void addDefaultExcludes() {
         int excludesLength = excludes == null ? 0 : excludes.length;
         String[] newExcludes;
-        newExcludes = new String[excludesLength + defaultExcludes.size()];
+        String[] defaultExcludesTemp = getDefaultExcludes();
+        newExcludes = new String[excludesLength + defaultExcludesTemp.length];
         if (excludesLength > 0) {
             System.arraycopy(excludes, 0, newExcludes, 0, excludesLength);
         }
-        String[] defaultExcludesTemp = getDefaultExcludes();
         for (int i = 0; i < defaultExcludesTemp.length; i++) {
             newExcludes[i + excludesLength] =
                 defaultExcludesTemp[i].replace('/', File.separatorChar)



Mime
View raw message