andsel commented on a change in pull request #2854:
URL: https://github.com/apache/rocketmq/pull/2854#discussion_r637405322
##########
File path: store/src/main/java/org/apache/rocketmq/store/CommitLog.java
##########
@@ -623,27 +646,22 @@ public long getBeginTimeInLock() {
mappedFile = this.mappedFileQueue.getLastMappedFile(0);
if (null == mappedFile) {
// XXX: warn and notify me
- log.error("create mapped file2 error, topic: " +
msg.getTopic() + " clientAddr: " + msg.getBornHostString());
- beginTimeInLock = 0;
- return CompletableFuture.completedFuture(new
PutMessageResult(PutMessageStatus.CREATE_MAPEDFILE_FAILED, result));
+ log.error("create mapped file error, topic: " +
msg.getTopic() + " clientAddr: " + msg.getBornHostString());
+ throw new
Exceptions.CreateMappedfileFailedException(result);
}
result = mappedFile.appendMessage(msg,
this.appendMessageCallback);
break;
case MESSAGE_SIZE_EXCEEDED:
case PROPERTIES_SIZE_EXCEEDED:
- beginTimeInLock = 0;
- return CompletableFuture.completedFuture(new
PutMessageResult(PutMessageStatus.MESSAGE_ILLEGAL, result));
+ throw new Exceptions.MessageIllegalException(result);
Review comment:
from https://www.baeldung.com/java-exceptions-performance throwing
exception is more costly than returning an error, but how many times do you
expect the exception is raised?
The condition under which is raised are:
- message size too big
- the properties are too big
- mapped file doesn't exists.
Do you think they happen so often to generate a performance problem in
throwing exception instead of returning error code?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]