openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r1171135 - /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCRegistry.java
Date Thu, 15 Sep 2011 15:28:19 GMT
Author: mikedd
Date: Thu Sep 15 15:28:19 2011
New Revision: 1171135

URL: http://svn.apache.org/viewvc?rev=1171135&view=rev
Log:
OPENJPA-2042: Use weak reference HashSet to store registered class listeners.
Submitted By: Jacob Nowosatka

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

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCRegistry.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCRegistry.java?rev=1171135&r1=1171134&r2=1171135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCRegistry.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCRegistry.java
Thu Sep 15 15:28:19 2011
@@ -27,6 +27,7 @@ import java.util.Map;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.lib.util.ReferenceMap;
 import org.apache.openjpa.lib.util.concurrent.ConcurrentReferenceHashMap;
+import org.apache.openjpa.lib.util.concurrent.ConcurrentReferenceHashSet;
 import org.apache.openjpa.util.UserException;
 
 /**
@@ -43,9 +44,12 @@ public class PCRegistry {
     // map of persistent classes to meta structures; weak so the VM can GC classes
     private static final Map<Class<?>,Meta> _metas = new ConcurrentReferenceHashMap(ReferenceMap.WEAK,

             ReferenceMap.HARD);
-
+    
     // register class listeners
-    private static final Collection<RegisterClassListener> _listeners = new LinkedHashSet<RegisterClassListener>();
+    // Weak reference prevents OutOfMemeoryError as described in OPENJPA-2042
+    private static final Collection<RegisterClassListener> _listeners =
+        new ConcurrentReferenceHashSet<RegisterClassListener>(
+            ConcurrentReferenceHashSet.WEAK);
 
     /**
      * Register a {@link RegisterClassListener}.



Mime
View raw message