Skip to content

Commit e44d3da

Browse files
stsypanovjhoeller
authored andcommitted
use Method in fixedInterceptorMap instead of String returned from Method::toString
1 parent e7dc439 commit e44d3da

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class CglibAopProxy implements AopProxy, Serializable {
112112
/** Dispatcher used for methods on Advised. */
113113
private final transient AdvisedDispatcher advisedDispatcher;
114114

115-
private transient Map<String, Integer> fixedInterceptorMap = Collections.emptyMap();
115+
private transient Map<Method, Integer> fixedInterceptorMap = Collections.emptyMap();
116116

117117
private transient int fixedInterceptorOffset;
118118

@@ -327,10 +327,11 @@ private Callback[] getCallbacks(Class<?> rootClass) throws Exception {
327327

328328
// TODO: small memory optimization here (can skip creation for methods with no advice)
329329
for (int x = 0; x < methods.length; x++) {
330-
List<Object> chain = this.advised.getInterceptorsAndDynamicInterceptionAdvice(methods[x], rootClass);
330+
Method method = methods[x];
331+
List<Object> chain = this.advised.getInterceptorsAndDynamicInterceptionAdvice(method, rootClass);
331332
fixedCallbacks[x] = new FixedChainStaticTargetInterceptor(
332333
chain, this.advised.getTargetSource().getTarget(), this.advised.getTargetClass());
333-
this.fixedInterceptorMap.put(methods[x].toString(), x);
334+
this.fixedInterceptorMap.put(method, x);
334335
}
335336

336337
// Now copy both the callbacks from mainCallbacks
@@ -762,12 +763,12 @@ private static class ProxyCallbackFilter implements CallbackFilter {
762763

763764
private final AdvisedSupport advised;
764765

765-
private final Map<String, Integer> fixedInterceptorMap;
766+
private final Map<Method, Integer> fixedInterceptorMap;
766767

767768
private final int fixedInterceptorOffset;
768769

769770
public ProxyCallbackFilter(
770-
AdvisedSupport advised, Map<String, Integer> fixedInterceptorMap, int fixedInterceptorOffset) {
771+
AdvisedSupport advised, Map<Method, Integer> fixedInterceptorMap, int fixedInterceptorOffset) {
771772

772773
this.advised = advised;
773774
this.fixedInterceptorMap = fixedInterceptorMap;
@@ -852,7 +853,7 @@ public int accept(Method method) {
852853
}
853854
return AOP_PROXY;
854855
}
855-
String key = method.toString();
856+
Method key = method;
856857
// Check to see if we have fixed interceptor to serve this method.
857858
// Else use the AOP_PROXY.
858859
if (isStatic && isFrozen && this.fixedInterceptorMap.containsKey(key)) {

spring-aop/src/main/java/org/springframework/aop/framework/ObjenesisCglibAopProxy.java

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public ObjenesisCglibAopProxy(AdvisedSupport config) {
5353

5454

5555
@Override
56-
@SuppressWarnings("unchecked")
5756
protected Object createProxyClassAndInstance(Enhancer enhancer, Callback[] callbacks) {
5857
Class<?> proxyClass = enhancer.createClass();
5958
Object proxyInstance = null;

0 commit comments

Comments
 (0)