Repository: incubator-ratis
Updated Branches:
  refs/heads/master 79c880d93 -> f574e576c


RATIS-155. TestSegmentedRaftLog and TestCacheEviction may fail due to 
NullPointerException.  Contributed by Jitendra Nath Pandey


Project: http://git-wip-us.apache.org/repos/asf/incubator-ratis/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ratis/commit/f574e576
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ratis/tree/f574e576
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ratis/diff/f574e576

Branch: refs/heads/master
Commit: f574e576c7098d563eea279596920178f7f5c288
Parents: 79c880d
Author: Tsz-Wo Nicholas Sze <[email protected]>
Authored: Fri Nov 24 16:24:41 2017 -0800
Committer: Tsz-Wo Nicholas Sze <[email protected]>
Committed: Fri Nov 24 16:24:41 2017 -0800

----------------------------------------------------------------------
 .../java/org/apache/ratis/server/storage/RaftLogWorker.java    | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/f574e576/ratis-server/src/main/java/org/apache/ratis/server/storage/RaftLogWorker.java
----------------------------------------------------------------------
diff --git 
a/ratis-server/src/main/java/org/apache/ratis/server/storage/RaftLogWorker.java 
b/ratis-server/src/main/java/org/apache/ratis/server/storage/RaftLogWorker.java
index 0c68cdc..2e1177f 100644
--- 
a/ratis-server/src/main/java/org/apache/ratis/server/storage/RaftLogWorker.java
+++ 
b/ratis-server/src/main/java/org/apache/ratis/server/storage/RaftLogWorker.java
@@ -94,8 +94,12 @@ class RaftLogWorker implements Runnable {
         RaftServerConfigKeys.Log.writeBufferSize(properties).getSizeInt();
     this.forceSyncNum = RaftServerConfigKeys.Log.forceSyncNum(properties);
     this.workerThread = new Thread(this, name);
+
+    // Server Id can be null in unit tests
+    Supplier<String> serverId = () -> raftServer == null || raftServer.getId() 
== null
+        ? "null" : raftServer.getId().toString();
     this.logFlushTimer = JavaUtils.memoize(() -> 
RatisMetricsRegistry.getRegistry()
-        .timer(MetricRegistry.name(RaftLogWorker.class, 
raftServer.getId().toString(),
+        .timer(MetricRegistry.name(RaftLogWorker.class, serverId.get(),
             "flush-time")));
   }
 

Reply via email to