When aspect weaving is on it causes a returned object to become null? off no issue
I'm new to creating my own Aspects and the aspect @Around is working in the sense that I see the output before and after the method executes.
The issue however is that when I have aspectJ enabled my return value from the service becomes null??? I remove the use of aspectj and it returns fine.
"results" here below is null when the aspects are enabled and not null when off...
Code:
@Test
public void getStuff() {
List<CharacteristicValueDef> results = service.getStuff();
logger.debug("results {}", results);
Assert.assertTrue(results.size() > 0);
}
If I log what service.getStuff() returns the list IS there... BUT after the method (getStuff()) exists aspectj must be setting it to null somehow since the logger above shows results as NULL.
Below is my aspect set up:
Code:
@Component
@Aspect
public class TimeMethodAspect {
private final static Logger logger = LoggerFactory.getLogger(TimeMethodAspect.class);
@Pointcut("within(com.foo.services.product..*)")
public void adviceMethods() {
}
@Around("adviceMethods()")
public void execute(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
logger.debug("entering {}",proceedingJoinPoint.getSignature());
StopWatch stopWatch = new StopWatch();
stopWatch.start();
proceedingJoinPoint.proceed();
stopWatch.stop();
logger.debug("Elapsed time calling {}: {}", proceedingJoinPoint.getSignature(), stopWatch);
}
}
The above does wrap my getStuff() call as it should, but any idea why my "results" returned from getStuff becomes null in my test case? (I'm using @RunWith(SpringJUnit4ClassRunner.class) and @ContextConfiguration(locations=.... )
Thanks for any help