Skip to content

Commit

Permalink
[ISSUE #9002] when bytebuffer is not enough, do not throw exception (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
leizhiyuan authored Dec 19, 2024
1 parent 93e2689 commit 16b6e53
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions store/src/main/java/org/apache/rocketmq/store/CommitLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,14 @@ private void doNothingForDeadCode(final Object obj) {
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();
Expand Down Expand Up @@ -628,6 +634,7 @@ public DispatchRequest checkMessageAndReturnSize(java.nio.ByteBuffer byteBuffer,

return dispatchRequest;
} catch (Exception e) {
log.error("checkMessageAndReturnSize failed, may can not dispatch", e);
}

return new DispatchRequest(-1, false /* success */);
Expand Down

0 comments on commit 16b6e53

Please sign in to comment.