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

shashikant 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 5b72ac7  RATIS-1029. NPE at MetricServerInterceptor.interceptCall 
(#174)
5b72ac7 is described below

commit 5b72ac7391b340758eaf69d124675e812db8f9e0
Author: Rui Wang <[email protected]>
AuthorDate: Wed Aug 12 03:46:25 2020 -0700

    RATIS-1029. NPE at MetricServerInterceptor.interceptCall (#174)
---
 .../grpc/metrics/intercept/server/MetricServerInterceptor.java      | 6 ++++--
 .../test/java/org/apache/ratis/server/impl/GroupInfoBaseTest.java   | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git 
a/ratis-grpc/src/main/java/org/apache/ratis/grpc/metrics/intercept/server/MetricServerInterceptor.java
 
b/ratis-grpc/src/main/java/org/apache/ratis/grpc/metrics/intercept/server/MetricServerInterceptor.java
index db19677..6ec5468 100644
--- 
a/ratis-grpc/src/main/java/org/apache/ratis/grpc/metrics/intercept/server/MetricServerInterceptor.java
+++ 
b/ratis-grpc/src/main/java/org/apache/ratis/grpc/metrics/intercept/server/MetricServerInterceptor.java
@@ -62,12 +62,14 @@ public class MetricServerInterceptor implements 
ServerInterceptor {
       Metadata requestHeaders,
       ServerCallHandler<R, S> next) {
     MethodDescriptor<R, S> method = call.getMethodDescriptor();
-    if(identifier == null){
+    if (identifier == null) {
       try {
         identifier = peerIdSupplier.get().toString();
-      } catch (Exception e){
+      } catch (Exception e) {
         identifier = defaultIdentifier;
       }
+    }
+    if (metrics == null) {
       metrics = new MessageMetrics(identifier, "server");
     }
     String metricNamePrefix = getMethodMetricPrefix(method);
diff --git 
a/ratis-server/src/test/java/org/apache/ratis/server/impl/GroupInfoBaseTest.java
 
b/ratis-server/src/test/java/org/apache/ratis/server/impl/GroupInfoBaseTest.java
index 26ee3ae..2b15b6b 100644
--- 
a/ratis-server/src/test/java/org/apache/ratis/server/impl/GroupInfoBaseTest.java
+++ 
b/ratis-server/src/test/java/org/apache/ratis/server/impl/GroupInfoBaseTest.java
@@ -50,7 +50,7 @@ public abstract class GroupInfoBaseTest<CLUSTER extends 
MiniRaftCluster>
 
     List<RaftPeer> peers = cluster.getPeers();
 
-    //Multi-raft with the second group
+    // Multi-raft with the second group
     RaftGroup group2 = RaftGroup.valueOf(RaftGroupId.randomId(), peers);
     for(RaftPeer peer : peers) {
       try(final RaftClient client = cluster.createClient(peer.getId())) {

Reply via email to