mirror of https://github.com/apache/openjpa.git
OPENJPA-2139 reset the BrokerFactory state if an Exception occured
This happens e.g. if the database is not available at the time the first DB access is performed. This did lead to a complete hook up until the whole application got restarted after the db reappeared. This fix will now ensure that all the column-key caching and stuff will be tried over again until the db is available again. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1311191 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
60e42eddda
commit
08b0dd2913
|
@ -612,8 +612,9 @@ public abstract class AbstractBrokerFactory
|
|||
_readOnly = true;
|
||||
|
||||
Log log = _conf.getLog(OpenJPAConfiguration.LOG_RUNTIME);
|
||||
if (log.isInfoEnabled())
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info(getFactoryInitializationBanner());
|
||||
}
|
||||
if (log.isTraceEnabled()) {
|
||||
Map<String,Object> props = _conf.toProperties(true);
|
||||
String lineSep = J2DoPrivHelper.getLineSeparator();
|
||||
|
@ -644,13 +645,18 @@ public abstract class AbstractBrokerFactory
|
|||
// avoid synchronization
|
||||
_conf.setReadOnly(Configuration.INIT_STATE_FREEZING);
|
||||
_conf.instantiateAll();
|
||||
if (_conf.isInitializeEagerly())
|
||||
_conf.setReadOnly(Configuration.INIT_STATE_FROZEN);
|
||||
if (_conf.isInitializeEagerly()) {
|
||||
_conf.setReadOnly(Configuration.INIT_STATE_FROZEN);
|
||||
}
|
||||
// fire an event for all the broker factory listeners
|
||||
// registered on the configuration.
|
||||
_conf.getBrokerFactoryEventManager().fireEvent(
|
||||
new BrokerFactoryEvent(this,
|
||||
BrokerFactoryEvent.BROKER_FACTORY_CREATED));
|
||||
} catch (RuntimeException e) {
|
||||
// if the db connection is not available we need to reset the state
|
||||
_readOnly = false;
|
||||
throw e;
|
||||
} finally {
|
||||
unlock();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue