Fixing NPE for absent blackhole config

Change-Id: I9e558a3182d82d49746f4202468fdb6edab012ff
diff --git a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/AppConfigHandler.java b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/AppConfigHandler.java
index 034ddfe..38d8aac 100644
--- a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/AppConfigHandler.java
+++ b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/AppConfigHandler.java
@@ -128,9 +128,11 @@
         SegmentRoutingAppConfig config =
                 srManager.cfgService.getConfig(srManager.appId, SegmentRoutingAppConfig.class);
         populateVRouter(deviceId, getMacAddresses(config));
-        config.blackholeIPs().forEach(ipPrefix -> {
-            srManager.routingRulePopulator.populateDefaultRouteBlackhole(deviceId, ipPrefix);
-        });
+        if (config != null) {
+            config.blackholeIPs().forEach(ipPrefix -> {
+                srManager.routingRulePopulator.populateDefaultRouteBlackhole(deviceId, ipPrefix);
+            });
+        }
     }
 
     private void populateVRouter(DeviceId deviceId, Set<MacAddress> pendingAdd) {
diff --git a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/config/SegmentRoutingAppConfig.java b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/config/SegmentRoutingAppConfig.java
index 9741f78..de6ffb9 100644
--- a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/config/SegmentRoutingAppConfig.java
+++ b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/config/SegmentRoutingAppConfig.java
@@ -24,6 +24,8 @@
 import org.onosproject.core.ApplicationId;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.config.Config;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.Set;
 
@@ -33,6 +35,9 @@
  * App configuration object for Segment Routing.
  */
 public class SegmentRoutingAppConfig extends Config<ApplicationId> {
+
+    private static Logger log = LoggerFactory.getLogger(SegmentRoutingAppConfig.class);
+
     private static final String VROUTER_MACS = "vRouterMacs";
     private static final String SUPPRESS_SUBNET = "suppressSubnet";
     private static final String SUPPRESS_HOST_BY_PORT = "suppressHostByPort";
@@ -55,7 +60,7 @@
      * Gets ips to blackhole from the config.
      *
      * @return Set of ips to blackhole, empty is not specified,
-     *         or null if not valid
+     * or null if not valid
      */
     public Set<IpPrefix> blackholeIPs() {
         if (!object.has(BLACKHOLE_IPS)) {
@@ -68,16 +73,14 @@
             IpPrefix address;
 
             String addrStr = jsonNode.asText(null);
-            if (addrStr == null) {
-                return null;
+            if (addrStr != null) {
+                try {
+                    address = IpPrefix.valueOf(addrStr);
+                    builder.add(address);
+                } catch (IllegalArgumentException e) {
+                    log.debug("Not adding {}", jsonNode, e);
+                }
             }
-            try {
-                address = IpPrefix.valueOf(addrStr);
-            } catch (IllegalArgumentException e) {
-                return null;
-            }
-
-            builder.add(address);
         }
         return builder.build();
     }