You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by "Joe Bergmark (JIRA)" <ji...@apache.org> on 2012/09/24 16:02:07 UTC

[jira] [Created] (OWB-706) Interceptor bindings on methods that come from an interface with a generic type may not work

Joe Bergmark created OWB-706:
--------------------------------

             Summary: Interceptor bindings on methods that come from an interface with a generic type may not work
                 Key: OWB-706
                 URL: https://issues.apache.org/jira/browse/OWB-706
             Project: OpenWebBeans
          Issue Type: Bug
          Components: Interceptor and Decorators
    Affects Versions: 1.1.5
            Reporter: Joe Bergmark
            Assignee: Joe Bergmark
            Priority: Minor


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.




--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira