Sonar suggestions - don't reuse formal parameter, guard agains NPE
Change-Id: I5bbdb950e6f1bec40d466344f45bcaf2d0d44135
diff --git a/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java b/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java
index 97e3cb4..df25281 100644
--- a/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java
+++ b/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java
@@ -349,7 +349,8 @@
}
@Override
- public void hostDetected(HostId hostId, HostDescription hostDescription, boolean replaceIps) {
+ public void hostDetected(HostId hostId, HostDescription initialHostDescription, boolean replaceIps) {
+ HostDescription hostDescription = initialHostDescription;
checkNotNull(hostId, HOST_ID_NULL);
checkValidity();
hostDescription = validateHost(hostDescription, hostId);
@@ -364,7 +365,7 @@
return;
}
- hostDescription = BasicHostOperator.combine(cfg, hostDescription);
+ hostDescription = BasicHostOperator.combine(cfg, initialHostDescription);
HostAnnotationConfig annoConfig = networkConfigService.getConfig(hostId, HostAnnotationConfig.class);
if (annoConfig != null) {
hostDescription = hostAnnotationOperator.combine(hostId, hostDescription, Optional.of(annoConfig));
@@ -550,7 +551,7 @@
}
} else if (event.configClass().equals(HostAnnotationConfig.class)) {
Host host = getHost(hostId);
- HostProvider hp = getProvider(host.providerId());
+ HostProvider hp = (host == null) ? null : getProvider(host.providerId());
HostDescription desc = (host == null) ? null : BasicHostOperator.descriptionOf(host);
Optional<Config> prevConfig = event.prevConfig();
log.debug("Host annotations: {} prevconfig {} desc {}", hostId, prevConfig, desc);