Skip to content

Commit 33628f5

Browse files
committed
Fix Cache bug
1 parent b339d75 commit 33628f5

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

core/src/main/java/top/niunaijun/blackreflection/BlackReflection.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,17 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
163163
}
164164
});
165165

166-
if (caller == null) {
167-
sProxyCache.put(clazz, o);
168-
} else {
169-
Map<Class<?>, Object> callerClassMap = sCallerProxyCache.get(caller);
170-
if (callerClassMap == null) {
171-
callerClassMap = new HashMap<>();
172-
sCallerProxyCache.put(caller, callerClassMap);
166+
if (CACHE) {
167+
if (caller == null) {
168+
sProxyCache.put(clazz, o);
169+
} else {
170+
Map<Class<?>, Object> callerClassMap = sCallerProxyCache.get(caller);
171+
if (callerClassMap == null) {
172+
callerClassMap = new HashMap<>();
173+
sCallerProxyCache.put(caller, callerClassMap);
174+
}
175+
callerClassMap.put(clazz, o);
173176
}
174-
callerClassMap.put(clazz, o);
175177
}
176178
return (T) o;
177179
} catch (ClassNotFoundException e) {

0 commit comments

Comments
 (0)