using wrong log type in try-catch exception handle.
in org.apache.rocketmq.spring.support.DefaultRocketMQListenerContainer#doConvertMessage method used log.info instead of log.error in exception handling.
private Object doConvertMessage(MessageExt messageExt) {
if (Objects.equals(messageType, MessageExt.class) || Objects.equals(messageType, org.apache.rocketmq.common.message.Message.class)) {
return messageExt;
} else {
String str = new String(messageExt.getBody(), Charset.forName(charset));
if (Objects.equals(messageType, String.class)) {
return str;
} else {
// If msgType not string, use objectMapper change it.
try {
// ignored
} catch (Exception e) {
// here it is 👇
log.info("convert failed. str:{}, msgType:{}", str, messageType);
throw new RuntimeException("cannot convert message to " + messageType, e);
}
}
}
}
log.info should print normal log, it shoud be using log.error instead of log.info
how to fix
private Object doConvertMessage(MessageExt messageExt) {
if (Objects.equals(messageType, MessageExt.class) || Objects.equals(messageType, org.apache.rocketmq.common.message.Message.class)) {
return messageExt;
} else {
String str = new String(messageExt.getBody(), Charset.forName(charset));
if (Objects.equals(messageType, String.class)) {
return str;
} else {
// If msgType not string, use objectMapper change it.
try {
// ignored
} catch (Exception e) {
// change like this
log.error("convert failed. str:{}, msgType:{},\n convert error msg: {}.", str, messageType, e.getMessage());
throw new RuntimeException("cannot convert message to " + messageType, e);
}
}
}
}
environment
describe
using wrong log type in try-catch exception handle.
in
org.apache.rocketmq.spring.support.DefaultRocketMQListenerContainer#doConvertMessage
method usedlog.info
instead oflog.error
in exception handling.log.info
should print normal log, it shoud be usinglog.error
instead oflog.info
how to fix