mirror of https://github.com/apache/openjpa.git
OPENJPA-2042: Diagnostics for Application Managed EntityManagerFactory leaks.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/2.0.x@1338900 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8052dfd4ee
commit
7b36aa53c5
|
@ -26,6 +26,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;
|
||||
|
||||
/**
|
||||
|
@ -44,7 +45,9 @@ public class PCRegistry {
|
|||
ReferenceMap.HARD);
|
||||
|
||||
// register class listeners
|
||||
private static final Collection<RegisterClassListener> _listeners = new LinkedList<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}.
|
||||
|
@ -201,10 +204,13 @@ public class PCRegistry {
|
|||
_metas.put(pcClass, meta);
|
||||
}
|
||||
synchronized (_listeners) {
|
||||
for (RegisterClassListener r : _listeners)
|
||||
for (RegisterClassListener r : _listeners) {
|
||||
if (r != null) {
|
||||
r.register(pcClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* De-Register all metadata associated with the given ClassLoader.
|
||||
|
|
Loading…
Reference in New Issue