This is an automated email from the ASF dual-hosted git repository.
jinrongtong pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git
The following commit(s) were added to refs/heads/develop by this push:
new 16b6e53263 [ISSUE #9002] when bytebuffer is not enough, do not throw
exception (#9003)
16b6e53263 is described below
commit 16b6e53263477794125a49d9f31a994a510970b7
Author: Lei Zhiyuan <[email protected]>
AuthorDate: Thu Dec 19 11:44:32 2024 +0800
[ISSUE #9002] when bytebuffer is not enough, do not throw exception (#9003)
* fix: when bytebuffer is not enough,we should wait for next instead of
throw exception
* fix: when bytebuffer is not enough,we should wait for next instead of
throw exception
---
store/src/main/java/org/apache/rocketmq/store/CommitLog.java | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
b/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
index d30691908b..ff96bf1066 100644
--- a/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
+++ b/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
@@ -432,8 +432,14 @@ public class CommitLog implements Swappable {
public DispatchRequest checkMessageAndReturnSize(java.nio.ByteBuffer
byteBuffer, final boolean checkCRC,
final boolean checkDupInfo, final boolean readBody) {
try {
+ if (byteBuffer.remaining() <= 4) {
+ return new DispatchRequest(-1, false /* fail */);
+ }
// 1 TOTAL SIZE
int totalSize = byteBuffer.getInt();
+ if (byteBuffer.remaining() < totalSize - 4) {
+ return new DispatchRequest(-1, false /* fail */);
+ }
// 2 MAGIC CODE
int magicCode = byteBuffer.getInt();
@@ -628,6 +634,7 @@ public class CommitLog implements Swappable {
return dispatchRequest;
} catch (Exception e) {
+ log.error("checkMessageAndReturnSize failed, may can not
dispatch", e);
}
return new DispatchRequest(-1, false /* success */);