diff options
author | Li Zi <li.zi30@zte.com.cn> | 2018-02-01 07:17:00 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-02-01 07:17:00 +0000 |
commit | 20c270053efed3721b8df55cf7a3b8c344c0f842 (patch) | |
tree | 096ee6855dd0b8a45e4736fb305541be3e10fd74 /esr-mgr/src/main | |
parent | 65d614f77561e8c8bb68e383f5de2fd47dd57eed (diff) | |
parent | 4cb06783a36e3fd3323a45bc0ba370f737574bc0 (diff) |
Merge "Fix the sonar issue."
Diffstat (limited to 'esr-mgr/src/main')
-rw-r--r-- | esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MsbHelper.java | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MsbHelper.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MsbHelper.java index 7452937..41c9d91 100644 --- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MsbHelper.java +++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MsbHelper.java @@ -16,16 +16,23 @@ package org.onap.aai.esr.externalservice.msb; import java.net.InetAddress; +import java.net.UnknownHostException; import java.util.HashSet; import java.util.Set; +import org.onap.aai.esr.exception.ExceptionUtil; +import org.onap.msb.sdk.discovery.common.RouteException; import org.onap.msb.sdk.discovery.entity.MicroServiceInfo; import org.onap.msb.sdk.httpclient.msb.MSBServiceClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.onap.msb.sdk.discovery.entity.Node; public class MsbHelper { private MSBServiceClient msbClient; + private static final Logger LOG = LoggerFactory.getLogger(MsbHelper.class); + public MsbHelper(MSBServiceClient msbClient) { super(); this.msbClient = msbClient; @@ -33,7 +40,7 @@ public class MsbHelper { - public void registerMsb() throws Exception { + public void registerMsb() throws RouteException { MicroServiceInfo msinfo = new MicroServiceInfo(); @@ -46,7 +53,12 @@ public class MsbHelper { Set<Node> nodes = new HashSet<>(); Node node1 = new Node(); - node1.setIp(InetAddress.getLocalHost().getHostAddress()); + try { + node1.setIp(InetAddress.getLocalHost().getHostAddress()); + } catch (UnknownHostException e) { + LOG.error("Got localhost failed when register service to MSB!", e); + throw ExceptionUtil.buildExceptionResponse(e.getMessage()); + } node1.setPort("9518"); nodes.add(node1); msinfo.setNodes(nodes); |