You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "LJiangTao (via GitHub)" <gi...@apache.org> on 2024/07/22 02:00:46 UTC
[I] The wrong log type is used for log printing during error handling [rocketmq-spring]
LJiangTao opened a new issue, #670:
URL: https://github.com/apache/rocketmq-spring/issues/670
## environment
```xml
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-spring-boot-starter</artifactId>
<version>2.3.0</version>
</dependency>
```
> current latest version also has issue.
## describe
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.
```java
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
```java
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:{}", str, messageType);
throw new RuntimeException("cannot convert message to " + messageType, e);
}
}
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] The wrong log type is used for log printing during error handling [rocketmq-spring]
Posted by "RockteMQ-AI (via GitHub)" <gi...@apache.org>.
RockteMQ-AI commented on issue #670:
URL: https://github.com/apache/rocketmq-spring/issues/670#issuecomment-5223768544
**Issue Evaluation**
Category: `type/bug` | Status: **Confirmed**
The wrong log type/level is used during error handling in the Spring starter. Error conditions are logged at incorrect levels (e.g., WARN instead of ERROR), making it difficult to monitor and alert on actual failures.
**Root Cause:** Inconsistent log level usage in exception handling paths.
**Impact:** Operations teams cannot reliably filter logs for error monitoring.
**Severity:** low — functional behavior is correct, but observability is degraded.
A fix should audit error handling paths and use appropriate log levels (ERROR for failures, WARN for recoverable issues).
---
*Automated evaluation by RockteMQ-AI*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org