yandrey321 commented on code in PR #1322:
URL: https://github.com/apache/ratis/pull/1322#discussion_r2598914017
##########
ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLogCache.java:
##########
@@ -614,10 +614,12 @@ long getLastIndexInClosedSegments() {
TermIndex getLastTermIndex() {
try (AutoCloseableLock readLock = closedSegments.readLock()) {
- return (openSegment != null && openSegment.getLastTermIndex() != null) ?
- openSegment.getLastTermIndex() :
- (closedSegments.isEmpty() ? null :
- closedSegments.get(closedSegments.size() -
1).getLastTermIndex());
+ TermIndex lastOpenIndex =
+ (openSegment != null) ? openSegment.getLastTermIndex() : null;
+ return lastOpenIndex != null
Review Comment:
IMHO this one would be easier to read and follow the logic:
if (lastOpenIndex != null) {
return lastOpenIndex
}
var closedSegmentsSize = closedSegments.size();
if (closedSegmentsSize > 0) {
return closedSegments.get(closedSegmentsSize).getLastTermIndex());
}
return null;
--
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]