szetszwo commented on PR #1049:
URL: https://github.com/apache/ratis/pull/1049#issuecomment-2013372374
> Without updates, the existing client code won't call getEntryRef either,
but getEntry which copies the returned LogEntryProto?
Client code will call `RaftLog.getEntryWithData(..)`. In the new code and
the change below, it will retain but not release the ref.
```java
//SegmentedRaftLog
public EntryWithData getEntryWithData(long index) throws
RaftLogIOException {
final ReferenceCountedObject<LogEntryProto> entryRef = retainLog(index);
```
this change
```java
@@ -323,17 +323,9 @@ public final class SegmentedRaftLog extends RaftLogBase
{
if (entryRef == null) {
throw new RaftLogIOException("Log entry not found: index = " + index);
}
- try {
- // TODO. The reference counted object should be passed to LogAppender
RATIS-2026.
- return getEntryWithData(entryRef.get());
- } finally {
- entryRef.release();
- }
- }
-
- private EntryWithData getEntryWithData(LogEntryProto entry) throws
RaftLogIOException {
+ LogEntryProto entry = entryRef.get();
if (!LogProtoUtils.isStateMachineDataEmpty(entry)) {
- return newEntryWithData(entry, null);
+ return newEntryWithData(entryRef, 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]