From cb9ea9efb379c7658f83078e6f7f6be580455ce8 Mon Sep 17 00:00:00 2001 From: Zhouxiang Zhan Date: Fri, 1 Mar 2024 11:11:19 +0800 Subject: [PATCH] Fix unboxing npe in SendMessageRequestHeader (#7873) --- .../header/SendMessageRequestHeader.java | 17 +++++++++++++---- .../header/SendMessageRequestHeaderV2.java | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/header/SendMessageRequestHeader.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/header/SendMessageRequestHeader.java index 17ce5126313..2efc94220df 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/header/SendMessageRequestHeader.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/header/SendMessageRequestHeader.java @@ -50,9 +50,9 @@ public class SendMessageRequestHeader extends TopicQueueRequestHeader { @CFNullable private Integer reconsumeTimes; @CFNullable - private boolean unitMode = false; + private Boolean unitMode; @CFNullable - private boolean batch = false; + private Boolean batch; private Integer maxReconsumeTimes; @Override @@ -136,6 +136,9 @@ public void setProperties(String properties) { } public Integer getReconsumeTimes() { + if (null == reconsumeTimes) { + return 0; + } return reconsumeTimes; } @@ -144,10 +147,13 @@ public void setReconsumeTimes(Integer reconsumeTimes) { } public boolean isUnitMode() { + if (null == unitMode) { + return false; + } return unitMode; } - public void setUnitMode(boolean isUnitMode) { + public void setUnitMode(Boolean isUnitMode) { this.unitMode = isUnitMode; } @@ -160,10 +166,13 @@ public void setMaxReconsumeTimes(final Integer maxReconsumeTimes) { } public boolean isBatch() { + if (null == batch) { + return false; + } return batch; } - public void setBatch(boolean batch) { + public void setBatch(Boolean batch) { this.batch = batch; } diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/header/SendMessageRequestHeaderV2.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/header/SendMessageRequestHeaderV2.java index 4b0d795bcd5..7a49722e92f 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/header/SendMessageRequestHeaderV2.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/header/SendMessageRequestHeaderV2.java @@ -52,7 +52,7 @@ public class SendMessageRequestHeaderV2 extends TopicQueueRequestHeader implemen @CFNullable private Integer j; // reconsumeTimes; @CFNullable - private Boolean k; // unitMode = false; + private Boolean k; // unitMode; private Integer l; // consumeRetryTimes