From 8d1f88756fb39c1f54b764aa12cad321c216b836 Mon Sep 17 00:00:00 2001 From: Tsz-Wo Nicholas Sze Date: Fri, 27 Dec 2024 09:44:34 -0800 Subject: [PATCH] Fix a bug. --- .../org/apache/ratis/server/leader/LogAppenderBase.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) {