The wrong log type is used for log printing during error handling
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 82/100
Research direction
Start in org.apache.rocketmq.spring.support.DefaultRocketMQListenerContainer#doConvertMessage and inspect the catch block around message conversion. Change the conversion-failure logging to the requested error-level form, then verify that the RuntimeException behavior remains unchanged and run the relevant existing tests.
Written by the indexing model from the issue text.
Description
environment
<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.
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);
}
}
}
}
- Dominant language
- Java
- Stars
- 2.3k
- Forks
- 942
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/rocketmq-spring
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
apache/rocketmq-spring#780 · 3 comments ·
-
编译报错 Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
apache/rocketmq-spring#692 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
apache/rocketmq-spring#678 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
apache/rocketmq-spring#609 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 25/100
apache/rocketmq-spring#776 · 8 comments ·
All issues in apache/rocketmq-spring
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100