[FELIX-3416] ConcurrentModificationException in DirectoryWatcher.findBundlesWithFragmentsToRefresh

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1348901 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java b/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
index 8600e0e..0fe5fa6 100644
--- a/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
+++ b/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
@@ -1259,6 +1259,7 @@
     }
 
     protected void findBundlesWithFragmentsToRefresh(Set toRefresh) {
+        Set fragments = new HashSet();
         for (Iterator iterator = toRefresh.iterator(); iterator.hasNext();) {
             Bundle b = (Bundle) iterator.next();
             if (b.getState() != Bundle.UNINSTALLED) {
@@ -1275,10 +1276,10 @@
                                 if (ver != null) {
                                     VersionRange v = VersionRange.parseVersionRange(ver);
                                     if (v.contains(VersionTable.getVersion((String) hostBundle.getHeaders().get(Constants.BUNDLE_VERSION)))) {
-                                        toRefresh.add(hostBundle);
+                                        fragments.add(hostBundle);
                                     }
                                 } else {
-                                    toRefresh.add(hostBundle);
+                                    fragments.add(hostBundle);
                                 }
                             }
                         }
@@ -1286,6 +1287,7 @@
                 }
             }
         }
+        toRefresh.addAll(fragments);
     }
 
     protected void findBundlesWithOptionalPackagesToRefresh(Set toRefresh) {