aspect

Aspectj exceptions handling on multiple matching advices

北慕城南 提交于 2021-02-05 10:39:14
问题 I have 2 aspects that are applied on the same method. When the method executes correctly I have no problem, everything is working fine and both aspects work as expected. The problem is when the method throw an exception. In these cases, the first aspect re-throw correctly the exception, but the second aspect is generating a nullpointerexception. I was able to reproduce the problem isolating the case on a unit test in a separated project. Those are the aspects (actually I removed all the logic

Aspectj exceptions handling on multiple matching advices

Deadly 提交于 2021-02-05 10:39:05
问题 I have 2 aspects that are applied on the same method. When the method executes correctly I have no problem, everything is working fine and both aspects work as expected. The problem is when the method throw an exception. In these cases, the first aspect re-throw correctly the exception, but the second aspect is generating a nullpointerexception. I was able to reproduce the problem isolating the case on a unit test in a separated project. Those are the aspects (actually I removed all the logic

Why jcabi-aspects annotations doesn't work

坚强是说给别人听的谎言 提交于 2021-01-29 07:50:47
问题 I have this code: public static void main(String[] args) { testAnnotation(); } @RetryOnFailure(attempts = 2) public static void testAnnotation() { System.out.println("enter here"); int x = 1/0; } But it runs the function just one time. This is the output: enter here Exception in thread "main" java.lang.ArithmeticException: / by zero at Main.testAnnotation(Main.java:16) at Main.main(Main.java:10) This my pom: <dependency> <groupId>com.jcabi</groupId> <artifactId>jcabi-aspects</artifactId>

@AfterReturning aspect executes in same transaction of pointcut method?

落爺英雄遲暮 提交于 2020-06-26 12:13:14
问题 I have a requirement to do a task after execution of a function. I have used Aspect for this. but I have some confusion. I have a function A() in a spring service. @Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) void A() { //Do Something } I have an @Afterreturning aspect on this function. @AfterReturning(pointcut = "execution(Sevice.saverecord(..)) ") public void processNotifications(JoinPoint jp) {} I want

@AfterReturning aspect executes in same transaction of pointcut method?

☆樱花仙子☆ 提交于 2020-06-26 12:11:47
问题 I have a requirement to do a task after execution of a function. I have used Aspect for this. but I have some confusion. I have a function A() in a spring service. @Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) void A() { //Do Something } I have an @Afterreturning aspect on this function. @AfterReturning(pointcut = "execution(Sevice.saverecord(..)) ") public void processNotifications(JoinPoint jp) {} I want

@AfterReturning aspect executes in same transaction of pointcut method?

情到浓时终转凉″ 提交于 2020-06-26 12:11:23
问题 I have a requirement to do a task after execution of a function. I have used Aspect for this. but I have some confusion. I have a function A() in a spring service. @Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) void A() { //Do Something } I have an @Afterreturning aspect on this function. @AfterReturning(pointcut = "execution(Sevice.saverecord(..)) ") public void processNotifications(JoinPoint jp) {} I want

AspectJ inter-type field not recognized in advice

北慕城南 提交于 2020-05-28 06:53:47
问题 I'm essentially trying to track the number of transfers for an Account class. Reading the docs here: https://www.eclipse.org/aspectj/doc/released/progguide/language-anatomy.html And on slide 48 and 49 here: https://www.eclipse.org/aspectj/doc/released/progguide/language-anatomy.html These tell me I should be able to do something like this: public aspect LoggingAspect { private int Account.transferCount = 0; private int Account.getTransferCount() { return transferCount; } pointcut

AspectJ inter-type field not recognized in advice

心已入冬 提交于 2020-05-28 06:53:41
问题 I'm essentially trying to track the number of transfers for an Account class. Reading the docs here: https://www.eclipse.org/aspectj/doc/released/progguide/language-anatomy.html And on slide 48 and 49 here: https://www.eclipse.org/aspectj/doc/released/progguide/language-anatomy.html These tell me I should be able to do something like this: public aspect LoggingAspect { private int Account.transferCount = 0; private int Account.getTransferCount() { return transferCount; } pointcut