New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify intended advice execution behavior in Spring version 5.2.7+ #26202
Comments
This seems to be a side effect of #25186 which was trying to make advice ordering more reliable. We'll try to revise this once more. |
It turns out that our revised advice ordering is actually correct and closely aligned with AspectJ semantics. Each of the distinct advice types of a particular aspect is conceptually meant to apply to the join point directly. As a consequence, an Also, As a solution, keep using your I've repurposed this ticket towards explicit documentation notes around the intended semantics. |
Thank you for the detailed explanation. My understanding regarding the execution order of advice types was inline with your explanation until I saw a change in behavior between versions. My original suggestion to the SO issue was to use Sample code @Before("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());
} Could you please review and confirm if that is expected? |
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.RELEASEFor 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
The text was updated successfully, but these errors were encountered: