Skip to content

Commit

Permalink
Evaluate thread-bound MethodInvocation only if it matches current Method
Browse files Browse the repository at this point in the history
Closes gh-26068
  • Loading branch information
jhoeller committed Jan 9, 2024
1 parent 7855986 commit 03b6e51
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -334,13 +334,15 @@ public boolean matches(Method method, Class<?> targetClass, Object... args) {
Object targetObject = null;
Object thisObject = null;
try {
MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation();
targetObject = mi.getThis();
if (!(mi instanceof ProxyMethodInvocation _pmi)) {
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
MethodInvocation curr = ExposeInvocationInterceptor.currentInvocation();
if (curr.getMethod() == method) {
targetObject = curr.getThis();
if (!(curr instanceof ProxyMethodInvocation currPmi)) {
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + curr);
}
pmi = currPmi;
thisObject = pmi.getProxy();
}
pmi = _pmi;
thisObject = pmi.getProxy();
}
catch (IllegalStateException ex) {
// No current invocation...
Expand Down

0 comments on commit 03b6e51

Please sign in to comment.