Merge remote-tracking branch 'origin/master'

This commit is contained in:
ascrutae 2016-08-03 00:13:43 +08:00
commit 61d797607a
1 changed files with 6 additions and 7 deletions

View File

@ -25,15 +25,16 @@ public class InterceptorInstanceLoader {
public static <T> T load(String className, ClassLoader targetClassLoader)
throws InvocationTargetException, IllegalAccessException, InstantiationException, ClassNotFoundException {
if (InterceptorInstanceLoader.class.getClassLoader().equals(targetClassLoader)) {
return (T) targetClassLoader.loadClass(className).newInstance();
}
String instanceKey = className + "_OF_" + targetClassLoader.getClass().getName() + "@" + Integer.toHexString(targetClassLoader.hashCode());
Object inst = INSTANCE_CACHE.get(instanceKey);
if (inst != null) {
return (T) inst;
}
if (InterceptorInstanceLoader.class.getClassLoader().equals(targetClassLoader)) {
return (T) targetClassLoader.loadClass(className).newInstance();
}
instanceLoadLock.lock();
try {
try {
@ -49,9 +50,7 @@ public class InterceptorInstanceLoader {
} catch (Exception e) {
throw new ClassNotFoundException(targetClassLoader.toString() + " load interceptor class:" + className + " failure.", e);
}
} finally
{
} finally {
instanceLoadLock.unlock();
}