Announcement Announcement Module
Collapse
No announcement yet.
AOP advising itself wrongly Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AOP advising itself wrongly

    Hi there

    I have got a piece of AspectJ Code wich I cant understand the behaviour.

    See:

    Code:
    
    package org.exceptionhandling.aspects;
    
    import org.exceptionhandling.handle.ExceptionHandle;
    import org.exceptionhandling.wrap.ExceptionWrap;
    
    public aspect ExceptionHandlingInterceptor {
    	
    	pointcut handlers ():  within(!org.exceptionhandling..*) ;
    	Object around() : handlers()  {
    
    		try {
    			return proceed();
    		} catch (Exception ex) {
    			throw new RuntimeException(ex);
    		}
    	}
    
    }
    The output of a simple throw new IllegalArgumentException("Mensagem de Ilegal Argument"); on the main method is

    Code:
    Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Mensagem de Ilegal Argument
    	at br.exceptionhandling.Main.main_aroundBody7$advice(Main.java:28)
    	at br.exceptionhandling.Main.main(Main.java:1)
    Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Mensagem de Ilegal Argument
    	at br.exceptionhandling.Main.send_aroundBody5$advice(Main.java:28)
    	at br.exceptionhandling.Main.main_aroundBody6(Main.java:8)
    	at br.exceptionhandling.Main.main_aroundBody7$advice(Main.java:25)
    	... 1 more
    Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Mensagem de Ilegal Argument
    	at br.exceptionhandling.Main.send_aroundBody17$advice(Main.java:28)
    	at br.exceptionhandling.Main.send(Main.java:1)
    	at br.exceptionhandling.Main.send_aroundBody4(Main.java:8)
    	at br.exceptionhandling.Main.send_aroundBody5$advice(Main.java:25)
    	... 3 more
    Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Mensagem de Ilegal Argument
    	at br.exceptionhandling.Main.ilegalArgument_aroundBody11$advice(Main.java:28)
    	at br.exceptionhandling.Main.send_aroundBody16(Main.java:15)
    	at br.exceptionhandling.Main.send_aroundBody17$advice(Main.java:25)
    	... 6 more
    Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Mensagem de Ilegal Argument
    	at br.exceptionhandling.ExceptionFactory.ilegalArgument_aroundBody5$advice(ExceptionFactory.java:28)
    	at br.exceptionhandling.ExceptionFactory.ilegalArgument(ExceptionFactory.java:1)
    	at br.exceptionhandling.Main.ilegalArgument_aroundBody10(Main.java:15)
    	at br.exceptionhandling.Main.ilegalArgument_aroundBody11$advice(Main.java:25)
    	... 8 more
    Caused by: java.lang.IllegalArgumentException: Mensagem de Ilegal Argument
    	at br.exceptionhandling.ExceptionFactory.init$_aroundBody2(ExceptionFactory.java:6)
    	at br.exceptionhandling.ExceptionFactory.init$_aroundBody3$advice(ExceptionFactory.java:25)
    	at br.exceptionhandling.ExceptionFactory.ilegalArgument_aroundBody4(ExceptionFactory.java:6)
    	at br.exceptionhandling.ExceptionFactory.ilegalArgument_aroundBody5$advice(ExceptionFactory.java:25)
    	... 11 more
    So , that means that the advise is acting before itself, but I thought the not (!), would prevent it.

    What am I missing?

    Thanks a lot!
Working...
X