[cdi-dev] Think I found bug with interceptor

Michael Remijan mjremijan at yahoo.com
Sun Nov 13 23:43:27 EST 2016


Greetings,
I am using:
<dependency>
    <groupId>org.jboss.weld.se</groupId>
    <artifactId>weld-se-core</artifactId>
    <version>3.0.0.Alpha15</version>
</dependency>
and I think I found a bug with the interceptors.  I wanted to ask about it first before I put it in Jira.
Basically, the interceptor I have defined works great if I annotate a method called by the CDI container, which in my case is an method observing for an event.  I have an ExceptionRetryInterceptor class and an ExceptionRetry annotation.  If I annotate an observer method like this:
@ExceptionRetrypublic void send(
        @Observes @Priority(SEND_EMAIL_MESSAGE) EmailEvent evnt
    ) throws MessagingException, IOException {....}

No problem, everything works fine.  I can see the interceptor code being called in my logs.  

Now here's the problem,  If I use this annotation on just a regular method which I call myself, it DOES NOT work.  So if I refactor the above example so the annotation is NOT on the observer method called by the container, then the doSend() method below does NOT get wrapped by the interceptor:

public void send(
        @Observes @Priority(SEND_EMAIL_MESSAGE) EmailEvent evnt
    ) throws MessagingException, IOException {      //....      doSend();}
@ExceptionRetrypublic void doSend() {....}  // this method does not get wrapped by the interceptor

I'm trying to figure out why. My ExceptionRetryInterceptor class has a @Priority set on it and that works fine.  But I've also tried setting <interceptors> in beans.xml but the doSend(){...} method still doesn't get wrapped.
Any thoughts/help?




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20161114/ef8851e1/attachment.html 


More information about the cdi-dev mailing list