Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #9002]when bytebuffer is not enough, do not throw exception #9003

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions store/src/main/java/org/apache/rocketmq/store/CommitLog.java
leizhiyuan marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,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 @@ -624,6 +630,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
Loading