[CORD-1925] Fix null pointer exception in DHCP relay store
NPE happened when remove DHCP record
Change-Id: I4b4c564d086c4e274aefa0ebce5d52cd622596d0
(cherry picked from commit 15813842f02e0410d9a7630362ea9adddcdf30ef)
diff --git a/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/store/DistributedDhcpRelayStore.java b/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/store/DistributedDhcpRelayStore.java
index 1e87ba6..38c0580 100644
--- a/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/store/DistributedDhcpRelayStore.java
+++ b/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/store/DistributedDhcpRelayStore.java
@@ -66,7 +66,13 @@
protected void activated() {
dhcpRecords = storageService.<HostId, DhcpRecord>eventuallyConsistentMapBuilder()
.withName("DHCP-Relay-Records")
- .withTimestampProvider((hostId, record) -> new WallClockTimestamp(record.lastSeen()))
+ .withTimestampProvider((hostId, record) -> {
+ if (record != null) {
+ return new WallClockTimestamp(record.lastSeen());
+ } else {
+ return new WallClockTimestamp();
+ }
+ })
.withSerializer(APP_KRYO)
.build();
listener = new InternalMapListener();