[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
This commit is contained in:
Lei Zhiyuan
2025-07-19 18:17:54 +08:00
committed by RongtongJin
parent e8e900c470
commit 89317508cd
@@ -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 */);