HHH-8383 ExceptionInInitializerError when changing System properties

while Environment class is initialized
This commit is contained in:
Brett Meyer 2013-08-13 14:58:32 -04:00
parent 4f2088856f
commit b1759cb7c2
1 changed files with 9 additions and 6 deletions

View File

@ -32,14 +32,13 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.Version;
import org.hibernate.bytecode.spi.BytecodeProvider;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.ConfigHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.jboss.logging.Logger;
/**
@ -240,10 +239,14 @@ public final class Environment implements AvailableSettings {
}
try {
GLOBAL_PROPERTIES.putAll( System.getProperties() );
}
catch (SecurityException se) {
LOG.unableToCopySystemProperties();
Properties systemProperties = System.getProperties();
// Must be thread-safe in case an application changes System properties during Hibernate initialization.
// See HHH-8383.
synchronized (systemProperties) {
GLOBAL_PROPERTIES.putAll(systemProperties);
}
} catch (SecurityException se) {
LOG.unableToCopySystemProperties();
}
verifyProperties(GLOBAL_PROPERTIES);