You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by ru...@apache.org on 2020/09/10 00:21:04 UTC
[incubator-ratis] branch master updated: RATIS-1059. Avoid NPE when
exportInfo is NULL in LogStateMachine.processArchiveLog (#195)
This is an automated email from the ASF dual-hosted git repository.
runzhiwang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ratis.git
The following commit(s) were added to refs/heads/master by this push:
new a4cedc2 RATIS-1059. Avoid NPE when exportInfo is NULL in LogStateMachine.processArchiveLog (#195)
a4cedc2 is described below
commit a4cedc2514f62683fef4f1ab20c67848f4c336e6
Author: Rui Wang <am...@users.noreply.github.com>
AuthorDate: Wed Sep 9 17:20:54 2020 -0700
RATIS-1059. Avoid NPE when exportInfo is NULL in LogStateMachine.processArchiveLog (#195)
* RATIS-1059. Avoid NPE when exportInfo is NULL in LogStateMachine.processArchiveLog
* trigger new CI check
---
.../org/apache/ratis/logservice/server/LogStateMachine.java | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/ratis-logservice/src/main/java/org/apache/ratis/logservice/server/LogStateMachine.java b/ratis-logservice/src/main/java/org/apache/ratis/logservice/server/LogStateMachine.java
index 02e9234..f49f9dd 100644
--- a/ratis-logservice/src/main/java/org/apache/ratis/logservice/server/LogStateMachine.java
+++ b/ratis-logservice/src/main/java/org/apache/ratis/logservice/server/LogStateMachine.java
@@ -623,12 +623,15 @@ public class LogStateMachine extends BaseStateMachine {
loc = archiveLog.getLocation();
ArchivalInfo exportInfo =
exportMap.putIfAbsent(loc, new ArchivalInfo(loc));
- if (exportInfo != null && exportInfo.getLastArchivedIndex() == archiveLog
- .getLastArchivedRaftIndex()) {
- throw new IllegalStateException("Export of " + logName + "for the given location " + loc
- + "is already present and in " + exportInfo.getStatus());
+ if (exportInfo != null) {
+ if (exportInfo.getLastArchivedIndex() == archiveLog
+ .getLastArchivedRaftIndex()) {
+ throw new IllegalStateException("Export of " + logName + "for the given location " + loc
+ + "is already present and in " + exportInfo.getStatus());
+ } else {
+ exportInfo.updateArchivalInfo(archiveLog);
+ }
}
- exportInfo.updateArchivalInfo(archiveLog);
}
if (loc == null) {
throw new IllegalArgumentException(isArchivalRequest ?