IVY-1589 Prevent UnsupportedOperationException on list.remove() while doing a FileUti...
authorJaikiran Pai <jaikiran@apache.org>
Wed, 15 Aug 2018 05:31:59 +0000 (11:01 +0530)
committerJaikiran Pai <jaikiran@apache.org>
Wed, 15 Aug 2018 05:31:59 +0000 (11:01 +0530)
src/java/org/apache/ivy/util/FileUtil.java

index 38168c0..5963d4e 100644 (file)
@@ -171,7 +171,7 @@ public final class FileUtil {
                 // existing folder, gather existing children
                 File[] children = dest.listFiles();
                 if (children != null) {
-                    existingChild = Arrays.asList(children);
+                    existingChild = new ArrayList<>(Arrays.asList(children));
                 }
             }
         } else {
@@ -185,7 +185,9 @@ public final class FileUtil {
                 // compute the destination file
                 File childDest = new File(dest, cf.getName());
                 // if file existing, 'mark' it as taken care of
-                existingChild.remove(childDest);
+                if (!existingChild.isEmpty()) {
+                    existingChild.remove(childDest);
+                }
                 if (cf.isDirectory()) {
                     deepCopy(cf, childDest, l, overwrite);
                 } else {