openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1311191 - /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
Date Mon, 09 Apr 2012 10:26:49 GMT
Author: struberg
Date: Mon Apr  9 10:26:49 2012
New Revision: 1311191

URL: http://svn.apache.org/viewvc?rev=1311191&view=rev
Log:
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.

Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java?rev=1311191&r1=1311190&r2=1311191&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
Mon Apr  9 10:26:49 2012
@@ -612,8 +612,9 @@ public abstract class AbstractBrokerFact
             _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 AbstractBrokerFact
             // 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();
         }



Mime
View raw message