Skip to content

Use Method in CglibAopProxy.fixedInterceptorMap instead of String returned from Method::toString #22258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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