This is an automated email from the ASF dual-hosted git repository.

williamsong pushed a commit to branch snapshot-3
in repository https://gitbox.apache.org/repos/asf/ratis.git

commit ba6e1604dacd2040ba4256d9ad59f31059fa6ab1
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()

Reply via email to