In a multithreaded application I use the great Apache Commons library. However, for some reason, half of my threads gets blocked when calling its getList and similar methods.
This is a sample of the threadump:
java.lang.Thread.State: BLOCKED (on object monitor)
at org.apache.commons.configuration.interpol.ConfigurationInterpolator. (ConfigurationInterpolator.java:138)
- locked <0x00000000855e6138> (a java.util.HashMap)
at org.apache.commons.configuration.AbstractConfiguration.createInterpolator(AbstractConfiguration.java:328)
at org.apache.commons.configuration.AbstractConfiguration.getSubstitutor(AbstractConfiguration.java:292)
- locked <0x00000000d7293058> (a org.apache.commons.configuration.SubsetConfiguration)
at org.apache.commons.configuration.PropertyConverter.interpolate(PropertyConverter.java:958)
at org.apache.commons.configuration.AbstractConfiguration.interpolate(AbstractConfiguration.java:446)
at org.apache.commons.configuration.SubsetConfiguration.interpolate(SubsetConfiguration.java:213)
at org.apache.commons.configuration.SubsetConfiguration.interpolate(SubsetConfiguration.java:218)
at org.apache.commons.configuration.AbstractConfiguration.interpolate(AbstractConfiguration.java:433)
at org.apache.commons.configuration.SubsetConfiguration.interpolate(SubsetConfiguration.java:224)
at org.apache.commons.configuration.AbstractConfiguration.getString(AbstractConfiguration.java:1039)
at org.apache.commons.configuration.AbstractConfiguration.getString(AbstractConfiguration.java:1018)
Every time a thread is blocked (by the getList or getInt or similar methods) the lock is in the ConfigurationInterplator class. By looking at its source, I understand that the instantiation of the class is synchronized - however I only need to be able to read the properties, and do not need interpolation every time.
Is there a build in way in Apache Commons to get over this limitation? For example do not take the interpolation step every time and cache it somehow?
Thanks, krisy