java - AspectJ and Spring: Exclude @After method execution when method throws an exception -


i have , aspect in spring based on aspectj:

@after("execution(* ...) public void stoptotaltimerandmarksucess(joinpoint joinpoint) {...}  @afterthrowing("execution(* c ..) public void markerror(joinpoint joinpoint) {...} 

i need exclude @after execution when under method throws , exception. when method throws exception executed both (@after , @afterthrowing).

you need @afterreturning annotation rather @after.

@afterreturning:

after returning advice runs when matched method execution returns normally. declared using @afterreturning annotation (...)

@after:

after (finally) advice runs matched method execution exits. declared using @after annotation. after advice must prepared handle both normal , exception return conditions. typically used releasing resources, etc.

http://docs.spring.io/spring/docs/current/spring-framework-reference/html/aop.html


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -