Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-3416

ConcurrentModificationException in DirectoryWatcher.findBundlesWithFragmentsToRefresh

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • fileinstall-3.2.0
    • fileinstall-3.2.4
    • File Install
    • None

    Description

      I recently upgraded to File Install 3.2.0, and while testing an application came across this exception:

      In main loop, we have serious trouble: java.util.ConcurrentModificationException
      java.util.ConcurrentModificationException
      at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793)
      at java.util.HashMap$KeyIterator.next(HashMap.java:828)
      at org.apache.felix.fileinstall.internal.DirectoryWatcher.findBundlesWithFragmentsToRefresh(DirectoryWatcher.java:1247)
      at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:475)
      at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:286)

      Looking at the code, in the findBundlesWithFragmentsToRefresh() method, I see it iterates over a set while adding to the set, which violates the contract of the java.util.HashSet instance passed into the method:

      protected void findBundlesWithFragmentsToRefresh(Set toRefresh) {
      for (Iterator iterator = toRefresh.iterator(); iterator.hasNext()

      { ... toRefresh.add(hostBundle); }

      }

      Perhaps a temporary Set is needed within the iteration, so the found bundles can be added to the toRefresh set after the iteration loop?

      Attachments

        Activity

          People

            gnodet Guillaume Nodet
            msqr Matt Magoffin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: