OPENJPA-1113 - Close off memory leak.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@781221 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Albert Lee 2009-06-03 00:20:03 +00:00
parent d875749226
commit 751a60b393
2 changed files with 4 additions and 27 deletions

View File

@ -24,10 +24,8 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.security.AccessController;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
@ -103,26 +101,6 @@ public class Reflection {
beanPropertiesNameCache.clear();
}
public static void flushCaches(Collection<ClassLoader> loaders) {
if (loaders.size() > 0) {
flushCache(loaders, getterMethodCache);
flushCache(loaders, setterMethodCache);
flushCache(loaders, beanPropertiesNameCache);
}
}
private static void flushCache(Collection<ClassLoader> loaders,
Map<Class<?>, ?> cache) {
for (Iterator<Class<?>> itr = cache.keySet().iterator();
itr.hasNext();) {
Class<?> cls = itr.next();
ClassLoader sLoader = cls.getClassLoader();
if (loaders.contains(sLoader)) {
itr.remove();
}
}
}
/**
* Return the getter method matching the given property name, optionally
* throwing an exception if none.
@ -132,19 +110,18 @@ public class Reflection {
if (m != null) {
return m;
}
prop = StringUtils.capitalize(prop);
String name = "get" + prop;
String capProp = StringUtils.capitalize(prop);
try {
// this algorithm searches for a get<prop> or is<prop> method in
// a breadth-first manner.
for (Class c = cls; c != null && c != Object.class;
c = c.getSuperclass()) {
m = getDeclaredMethod(c, name, null);
m = getDeclaredMethod(c, "get" + capProp, null);
if (m != null) {
setGetterMethod(cls, prop, m);
return m;
} else {
m = getDeclaredMethod(c, "is" + prop, null);
m = getDeclaredMethod(c, "is" + capProp, null);
if (m != null && (m.getReturnType() == boolean.class
|| m.getReturnType() == Boolean.class)) {
setGetterMethod(cls, prop, m);

View File

@ -411,7 +411,7 @@ public abstract class AbstractBrokerFactory
PCRegistry.removeRegisterClassListener
(_conf.getMetaDataRepositoryInstance());
}
Reflection.flushCaches(_pcClassLoaders);
Reflection.flushCaches();
_conf.close();
_closed = true;
Log log = _conf.getLog(OpenJPAConfiguration.LOG_RUNTIME);