From 54266538192a558c6d80725c25912005090e14c4 Mon Sep 17 00:00:00 2001 From: Anu Engineer Date: Mon, 17 Dec 2018 12:17:09 -0800 Subject: [PATCH] HDDS-908: NPE in TestOzoneRpcClient. Contributed by Ajay Kumar. --- .../org/apache/hadoop/ozone/om/OzoneManager.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java index a044bc24d7f..f41eb88c2f5 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java @@ -1438,11 +1438,14 @@ public final class OzoneManager extends ServiceRuntimeInfoImpl .setNodeType(HddsProtos.NodeType.DATANODE) .setHostname(datanode.getHostName()); - dnServiceInfoBuilder.addServicePort(ServicePort.newBuilder() - .setType(ServicePort.Type.HTTP) - .setValue(DatanodeDetails.getFromProtoBuf(datanode) - .getPort(DatanodeDetails.Port.Name.REST).getValue()) - .build()); + if(DatanodeDetails.getFromProtoBuf(datanode) + .getPort(DatanodeDetails.Port.Name.REST) != null) { + dnServiceInfoBuilder.addServicePort(ServicePort.newBuilder() + .setType(ServicePort.Type.HTTP) + .setValue(DatanodeDetails.getFromProtoBuf(datanode) + .getPort(DatanodeDetails.Port.Name.REST).getValue()) + .build()); + } services.add(dnServiceInfoBuilder.build()); }