-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Description
Affects: 5.2.7.RELEASE
StackOverflow question : https://stackoverflow.com/q/65032499/4214241
Sample Github project shared for the question : https://github.com/RitamChakraborty/bank_transaction_springaop/tree/r_g_answer
Issue descrption :
The following @AfterThrowing
advice does not work as expected in Spring versions above : 5.2.6.RELEASE
@After("execution(public void dev.ritam.model.Bank.setTempPin(..))")
public void validatePin() {
if (bank.getPinCode() != bank.getTempPin()) {
throw new RuntimeException("Wrong Pin");
} else {
System.out.println("Correct Pin");
}
}
@AfterThrowing(value = "execution(public void dev.ritam.model.Bank.setTempPin(..))", throwing = "e")
public void logException(Exception e) {
System.out.println(e.getMessage());
}
For spring versions above : 5.2.6.RELEASE ( tested with releases 5.2.7.RELEASE,5.2.8.RELEASE,5.2.9.RELEASE,5.3.1)
@AfterThrowing
advice does not execute on exception from @After
advice. The same results if @After
advice is replaced with @Before
.
For spring versions equal to or below : 5.2.6.RELEASE ( tested with releases 5.2.6.RELEASE,5.2.5.RELEASE,5.2.4.RELEASE, 5.2.3.RELEASE) , the advice happens from @AfterThrowing
on exception from @After