0 Replies Latest reply on Nov 3, 2009 8:59 AM by adrian.brock

    Thread safety and collections

      https://jira.jboss.org/jira/browse/JBOSGI-199

      I spotted while I was looking at how the osgi-framework code uses the
      metadata that there are a number of places using unsynchronized HashMap, ArrayList,
      etc. for mutable data.

      The original one I spotted was a cache of attributes, but searching for HashMap
      I found others introduced in the BundleManager and the Resolver.

      Besides not being thread safe - for things like HashMap or LinkedList this can
      cause the code to go into a infinite loop when links end up pointing at themselves
      due to concurrent modification.

      I've only looked at and corrected the framework code. But there's obviously
      other places that have this problem, e.g.
      /jboss-osgi-deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java
      has an unsynchronized HashMap to track deployments.