[jboss-dev-forums] [JBoss OSGi Development] - Thread safety and collections

adrian@jboss.org do-not-reply at jboss.com
Tue Nov 3 08:59:47 EST 2009


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.

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4263690#4263690

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4263690



More information about the jboss-dev-forums mailing list