I want to use @EventListener annotation with condition attribute on proxied object. The EL expression uses function's argument. But during runtime the org.springframework.core.LocalVariableTableParameterNameDiscoverer cannot read debug information from CGLIB generated proxy and that is why parameters are not accessible. As a result I get
org.springframework.expression.spel.SpelEvaluationException: EL1007E:(pos 92): Property or field 'prop' cannot be found on null
class InterestedInEvent {
@EventListener(classes = SomeEvent.class, condition="#event.prop!=null")
@CacheEvict(cacheNames = CACHE_FOR_SOMETHING, allEntries = true)
public void onEvent(SomeEvent event) {
logger.debug("Chache {} has been cleaned, event={}", CACHE_FOR_SOMETHING, event);
}
}
How I can expose names of arguments or how to make spring to analyse original class and not proxy?
I've had a similar problem and found a workaround by using #root.event instead of #event.