szetszwo commented on code in PR #1081:
URL: https://github.com/apache/ratis/pull/1081#discussion_r1592863085
##########
ratis-server/src/main/java/org/apache/ratis/server/leader/LogAppenderBase.java:
##########
@@ -271,18 +271,21 @@ protected
ReferenceCountedObject<AppendEntriesRequestProto> nextAppendEntriesReq
return null;
}
- final List<LogEntryProto> protos =
buffer.pollList(getHeartbeatWaitTimeMs(), EntryWithData::getEntry,
- (entry, time, exception) -> LOG.warn("Failed to get " + entry
- + " in " + time.toString(TimeUnit.MILLISECONDS, 3), exception));
- for (EntryWithData entry : buffer) {
- // Release remaining entries.
- offered.remove(entry.getIndex()).release();
+ try {
Review Comment:
Let's `try` only `pollList`, i.e.
```java
final List<LogEntryProto> protos;
try {
protos = buffer.pollList(getHeartbeatWaitTimeMs(),
EntryWithData::getEntry,
(entry, time, exception) -> LOG.warn("Failed to get {} in {}",
entry, time.toString(TimeUnit.MILLISECONDS, 3), exception));
} finally {
for (EntryWithData entry : buffer) {
// Release remaining entries.
offered.remove(entry.getIndex()).release();
}
buffer.clear();
}
assertProtos(protos, followerNext, previous, snapshotIndex);
AppendEntriesRequestProto appendEntriesProto =
leaderState.newAppendEntriesRequestProto(follower, protos, previous,
callId);
return ReferenceCountedObject.delegateFrom(offered.values(),
appendEntriesProto);
}
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]