Fixing sonarqube and avoiding a potential NPE
Change-Id: I82169648b7f3f549686cfe2ca643c1bd6d865698
(cherry picked from commit a8dd99fad65e901ba0acb9ab04779fab007d5062)
diff --git a/apps/dhcprelay/app/src/main/java/org/onosproject/dhcprelay/DhcpRelayManager.java b/apps/dhcprelay/app/src/main/java/org/onosproject/dhcprelay/DhcpRelayManager.java
index ea230a4..2ba8702 100644
--- a/apps/dhcprelay/app/src/main/java/org/onosproject/dhcprelay/DhcpRelayManager.java
+++ b/apps/dhcprelay/app/src/main/java/org/onosproject/dhcprelay/DhcpRelayManager.java
@@ -71,6 +71,7 @@
import org.onosproject.mastership.MastershipService;
import org.onosproject.routing.fpm.api.FpmRecord;
import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
import org.onosproject.net.Host;
import org.onosproject.net.config.Config;
import org.onosproject.net.device.DeviceEvent;
@@ -126,7 +127,7 @@
.build();
private final Logger log = LoggerFactory.getLogger(getClass());
private final InternalConfigListener cfgListener = new InternalConfigListener();
- protected CopyOnWriteArraySet hostAutoRelearnEnabledDevices = new CopyOnWriteArraySet();
+ private CopyOnWriteArraySet<DeviceId> hostAutoRelearnEnabledDevices = new CopyOnWriteArraySet<DeviceId>();
private final Set<ConfigFactory> factories = ImmutableSet.of(
new ConfigFactory<ApplicationId, DefaultDhcpRelayConfig>(APP_SUBJECT_FACTORY,
@@ -779,6 +780,7 @@
.findFirst().orElse(null);
if (senderInterface == null) {
log.warn("Cannot get sender interface for from packet, abort... vlan {}", vlanId.toString());
+ return;
}
MacAddress senderMacAddress = senderInterface.mac();
byte[] senderIpAddress = IPv6.getLinkLocalAddress(senderMacAddress.toBytes());