diff --git a/ratis-server/src/main/java/org/apache/ratis/server/leader/LogAppenderBase.java b/ratis-server/src/main/java/org/apache/ratis/server/leader/LogAppenderBase.java index 8e428c8bc8..22cd16860d 100644 --- a/ratis-server/src/main/java/org/apache/ratis/server/leader/LogAppenderBase.java +++ b/ratis-server/src/main/java/org/apache/ratis/server/leader/LogAppenderBase.java @@ -339,7 +339,11 @@ protected ReferenceCountedObject nextAppendEntriesReq assertProtos(protos, followerNext, previous, snapshotIndex); AppendEntriesRequestProto appendEntriesProto = leaderState.newAppendEntriesRequestProto(follower, protos, previous, callId); - return ReferenceCountedObject.wrap(appendEntriesProto, entryList::retain, entryList::release); + final ReferenceCountedObject ref = ReferenceCountedObject.wrap( + appendEntriesProto, entryList::retain, entryList::release); + ref.retain(); + entryList.release(); + return ref; } private void assertProtos(List protos, long nextIndex, TermIndex previous, long snapshotIndex) {