Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.1.5
-
None
Description
If you apply an interceptor binding to a method that implements an interface that has a generic type, the interceptor might not be executed.
I'll write some unit tests, but I think the scenario is something like the following:
public interface Foo<T>{
public void doSomething<T>
}
public class Bar implements Foo<String>{
@MyInterceptorBinding
public void doSomething<String>
}
When a contextual reference of Bar is cast to Foo, or even to Foo<String>, calls to doSomething are no longer intercepted.
What seems to be happening is that due to type erasure, Bar really has to implement Foo<Object>, so the JDK adds a bridge method doSomething(Object) to Bar that under the covers just calls doSomething(String). The handler doesn't recognize that doSomething(Object) will call doSomething(String) and therefore doesn't run the interceptor.
While the problem is complex, I believe the solution is pretty easy (at least for the Javassist case). We can just add a check for bridge methods to the new MethodFilter (probably rename it to something less specific than FinalizeMethodFilter) so that doSomethign(String) will get called on the proxy and we will properly run the interceptor then rather than passing the call to doSomething(Object) down to the proxied instance.
This problem goes back to version 1.0, and its a very edge case, so I don't think it has to go into 1.1.6.
Attachments
Issue Links
- relates to
-
OWB-828 broken proxies in case of bridge methods
- Closed