Skip to content

Commit

Permalink
use Method in fixedInterceptorMap instead of String returned from Met…
Browse files Browse the repository at this point in the history
…hod::toString
  • Loading branch information
stsypanov authored and jhoeller committed Feb 15, 2019
1 parent e7dc439 commit e44d3da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class CglibAopProxy implements AopProxy, Serializable {
/** Dispatcher used for methods on Advised. */
private final transient AdvisedDispatcher advisedDispatcher;

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

private transient int fixedInterceptorOffset;

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

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

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

private final AdvisedSupport advised;

private final Map<String, Integer> fixedInterceptorMap;
private final Map<Method, Integer> fixedInterceptorMap;

private final int fixedInterceptorOffset;

public ProxyCallbackFilter(
AdvisedSupport advised, Map<String, Integer> fixedInterceptorMap, int fixedInterceptorOffset) {
AdvisedSupport advised, Map<Method, Integer> fixedInterceptorMap, int fixedInterceptorOffset) {

this.advised = advised;
this.fixedInterceptorMap = fixedInterceptorMap;
Expand Down Expand Up @@ -852,7 +853,7 @@ public int accept(Method method) {
}
return AOP_PROXY;
}
String key = method.toString();
Method key = method;
// Check to see if we have fixed interceptor to serve this method.
// Else use the AOP_PROXY.
if (isStatic && isFrozen && this.fixedInterceptorMap.containsKey(key)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public ObjenesisCglibAopProxy(AdvisedSupport config) {


@Override
@SuppressWarnings("unchecked")
protected Object createProxyClassAndInstance(Enhancer enhancer, Callback[] callbacks) {
Class<?> proxyClass = enhancer.createClass();
Object proxyInstance = null;
Expand Down

0 comments on commit e44d3da

Please sign in to comment.