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 be497d5c4 RATIS-2048. Fix SimpleStateMachineStorage potential NPE
exception (#1056)
be497d5c4 is described below
commit be497d5c472038242f8493ef5e56b56b7ce69ef1
Author: Potato <[email protected]>
AuthorDate: Sat Mar 23 00:58:31 2024 +0800
RATIS-2048. Fix SimpleStateMachineStorage potential NPE exception (#1056)
---
.../org/apache/ratis/statemachine/impl/SimpleStateMachineStorage.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git
a/ratis-server/src/main/java/org/apache/ratis/statemachine/impl/SimpleStateMachineStorage.java
b/ratis-server/src/main/java/org/apache/ratis/statemachine/impl/SimpleStateMachineStorage.java
index 37e94a8a0..88cc57dab 100644
---
a/ratis-server/src/main/java/org/apache/ratis/statemachine/impl/SimpleStateMachineStorage.java
+++
b/ratis-server/src/main/java/org/apache/ratis/statemachine/impl/SimpleStateMachineStorage.java
@@ -116,7 +116,7 @@ public class SimpleStateMachineStorage implements
StateMachineStorage {
final List<SingleFileSnapshotInfo> allSnapshotFiles =
getSingleFileSnapshotInfos(stateMachineDir.toPath());
- if (allSnapshotFiles.size() >
snapshotRetentionPolicy.getNumSnapshotsRetained()) {
+ if (allSnapshotFiles.size() > numSnapshotsRetained) {
allSnapshotFiles.sort(Comparator.comparing(SingleFileSnapshotInfo::getIndex).reversed());
allSnapshotFiles.subList(numSnapshotsRetained, allSnapshotFiles.size())
.stream()