|
When I start my program I set some System properties. At the same time Hibernate is started and the classes initialized. This calls the static block in Environment which copies the System properties to GLOBAL_PROPERTIES. This is not thread-safe although Properties/Hashtables are used. In the javadoc it says, that the Hashtable has to be synchronized when an iterator is used.
Change it from:
try {
GLOBAL_PROPERTIES.putAll(systemProperties);
} catch (SecurityException se) {
LOG.unableToCopySystemProperties();
}
to
try {
Properties systemProperties = System.getProperties();
synchronized (systemProperties) {
GLOBAL_PROPERTIES.putAll(systemProperties);
}
} catch (SecurityException se) {
LOG.unableToCopySystemProperties();
}
I attached a small test case which can reproduce this issue. It is very annoying because it happens randomly.
|