openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwsut...@apache.org
Subject svn commit: r502392 - /incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
Date Thu, 01 Feb 2007 22:53:21 GMT
Author: kwsutter
Date: Thu Feb  1 14:53:20 2007
New Revision: 502392

URL: http://svn.apache.org/viewvc?view=rev&rev=502392
Log:
Changes for OPENJPA-115.  Removed the explicit lock/unlock invocations when obtaining an EM
(broker).  Changed
_brokers to use ConcurrentReferenceHashSet (with weak references).  And, due to the weak references
(probable
cause), I had to check for nulls when iterating through the _brokers during the close processing.

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

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java?view=diff&rev=502392&r1=502391&r2=502392
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
Thu Feb  1 14:53:20 2007
@@ -37,6 +37,7 @@
 import org.apache.openjpa.lib.log.Log;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.lib.util.ReferenceHashSet;
+import org.apache.openjpa.lib.util.concurrent.ConcurrentReferenceHashSet;
 import org.apache.openjpa.lib.util.concurrent.ReentrantLock;
 import org.apache.openjpa.meta.MetaDataRepository;
 import org.apache.openjpa.util.GeneralException;
@@ -73,8 +74,8 @@
     private transient Map _transactional = new HashMap();
 
     // weak-ref tracking of open brokers
-    private transient Collection _brokers = new ReferenceHashSet
-        (ReferenceHashSet.WEAK);
+    private transient Collection _brokers = new ConcurrentReferenceHashSet
+        (ConcurrentReferenceHashSet.WEAK);
 
     // cache the class names loaded from the persistent classes property so
     // that we can re-load them for each new broker
@@ -141,7 +142,6 @@
 
     public Broker newBroker(String user, String pass, boolean managed,
         int connRetainMode, boolean findExisting) {
-        lock();
         try {
             assertOpen();
             makeReadOnly();
@@ -181,8 +181,6 @@
             throw ke;
         } catch (RuntimeException re) {
             throw new GeneralException(re);
-        } finally {
-            unlock();
         }
     }
 
@@ -289,7 +287,7 @@
             Broker broker;
             for (Iterator itr = _brokers.iterator(); itr.hasNext();) {
                 broker = (Broker) itr.next();
-                if (!broker.isClosed())
+                if ((broker != null) && (!broker.isClosed()))
                     broker.close();
             }
 
@@ -363,7 +361,8 @@
 
         // reset these transient fields to empty values
         _transactional = new HashMap();
-        _brokers = new ReferenceHashSet(ReferenceHashSet.WEAK);
+        _brokers = new ConcurrentReferenceHashSet(
+                ConcurrentReferenceHashSet.WEAK);
 
         makeReadOnly();
         return this;



Mime
View raw message