You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by sz...@apache.org on 2021/11/12 01:59:14 UTC
[ratis] branch master updated: RATIS-1432. fix
SegmentedRaftLogCache#getTotalCacheSize Null pointer exception (#530)
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/ratis.git
The following commit(s) were added to refs/heads/master by this push:
new ad22fbf RATIS-1432. fix SegmentedRaftLogCache#getTotalCacheSize Null pointer exception (#530)
ad22fbf is described below
commit ad22fbf8ce4a581b721755442400d036b51235d2
Author: hao guo <gu...@360.cn>
AuthorDate: Fri Nov 12 09:59:06 2021 +0800
RATIS-1432. fix SegmentedRaftLogCache#getTotalCacheSize Null pointer exception (#530)
---
.../apache/ratis/server/raftlog/segmented/SegmentedRaftLogCache.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLogCache.java b/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLogCache.java
index 3878c4b..914f19f 100644
--- a/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLogCache.java
+++ b/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLogCache.java
@@ -403,7 +403,8 @@ public class SegmentedRaftLogCache {
}
public long getTotalCacheSize() {
- return closedSegments.getTotalCacheSize() + openSegment.getTotalCacheSize();
+ return closedSegments.getTotalCacheSize() +
+ Optional.ofNullable(openSegment).map(LogSegment::getTotalCacheSize).orElse(0L);
}
boolean shouldEvict() {