symious commented on code in PR #1322:
URL: https://github.com/apache/ratis/pull/1322#discussion_r2604866896


##########
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:
   Reverted and use tmpSegment to avoid NPE.



-- 
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]

Reply via email to