I have implemented a CommandHandlerInterceptor extending the LoggingInterceptor.
The goal is to log the command and its payload. It works fine for all the create commands but fails with an exception like.
`
[UpdateBagCommand] executed successfully with a [null] return value
`
The execution of the command happens and the event is also generated.
It fails in the following method of the Logging Interceptor, pretty much the object returnValue comes as null.
@Override
public Object handle(UnitOfWork<? extends T> unitOfWork, InterceptorChain interceptorChain)
throws Exception {
T message = unitOfWork.getMessage();
logger.info("Incoming message: [{}]", message.getPayloadType().getSimpleName());
try {
Object returnValue = interceptorChain.proceed();
logger.info("[{}] executed successfully with a [{}] return value",
message.getPayloadType().getSimpleName(),
returnValue == null ? "null" : returnValue.getClass().getSimpleName());
return returnValue;
} catch (Exception t) {
logger.warn(format("[%s] execution failed:", message.getPayloadType().getSimpleName()), t);
throw t;
}
}