This is an automated email from the ASF dual-hosted git repository.

szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ratis.git


The following commit(s) were added to refs/heads/master by this push:
     new 008c009  RATIS-577. NPE in LogAppender while creating a new request.
008c009 is described below

commit 008c0093fed0cfd7e53b7d455621e1ec794d6f38
Author: Tsz Wo Nicholas Sze <[email protected]>
AuthorDate: Thu Jun 13 13:44:47 2019 -0700

    RATIS-577. NPE in LogAppender while creating a new request.
---
 .../apache/ratis/server/raftlog/segmented/SegmentedRaftLog.java    | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git 
a/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLog.java
 
b/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLog.java
index a5d261f..1586ecb 100644
--- 
a/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLog.java
+++ 
b/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLog.java
@@ -178,8 +178,8 @@ public class SegmentedRaftLog extends RaftLog {
   @Override
   public LogEntryProto get(long index) throws RaftLogIOException {
     checkLogState();
-    LogSegment segment;
-    LogRecordWithEntry recordAndEntry;
+    final LogSegment segment;
+    final LogRecordWithEntry recordAndEntry;
     try (AutoCloseableLock readLock = readLock()) {
       segment = cache.getSegment(index);
       if (segment == null) {
@@ -203,6 +203,9 @@ public class SegmentedRaftLog extends RaftLog {
   @Override
   public EntryWithData getEntryWithData(long index) throws RaftLogIOException {
     final LogEntryProto entry = get(index);
+    if (entry == null) {
+      throw new RaftLogIOException("Log entry not found: index = " + index);
+    }
     if (!ServerProtoUtils.shouldReadStateMachineData(entry)) {
       return new EntryWithData(entry, null);
     }

Reply via email to