commit | 2c142c52482c5f5ca7f1b0e83d20b866c19a8e22 | [log] [tgz] |
---|---|---|
author | Ray Milkey <ray@opennetworking.org> | Thu Nov 16 16:46:04 2017 -0800 |
committer | Thomas Vachuska <tom@opennetworking.org> | Fri Nov 17 01:17:13 2017 +0000 |
tree | 781c490da7848b726aa9f1dd8af7a839a9053518 | |
parent | 0b80972fa953cf02b68b7967be3e9bf0d4b29ba2 [diff] |
Fix race condition - if the device manager is not ready when a packet arrives, drop it rather than NPE Change-Id: I601b4ce1d449b169059a3390441dcfa58b800db3
diff --git a/core/net/src/main/java/org/onosproject/net/packet/impl/PacketDriverProvider.java b/core/net/src/main/java/org/onosproject/net/packet/impl/PacketDriverProvider.java index 78d1a75..be9551f 100644 --- a/core/net/src/main/java/org/onosproject/net/packet/impl/PacketDriverProvider.java +++ b/core/net/src/main/java/org/onosproject/net/packet/impl/PacketDriverProvider.java
@@ -61,6 +61,10 @@ } private PacketProgrammable getPacketProgrammable(DeviceId deviceId) { + if (deviceService == null) { + log.debug("Packet encountered but device service is not ready, dropping"); + return null; + } Device device = deviceService.getDevice(deviceId); if (device.is(PacketProgrammable.class)) { return device.as(PacketProgrammable.class);
diff --git a/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java b/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java index bace763..1ecf5b4 100644 --- a/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java +++ b/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java
@@ -130,8 +130,8 @@ appId = coreService.getAppId(CoreService.CORE_APP_NAME); store.setDelegate(delegate); deviceService.addListener(deviceListener); - store.existingRequests().forEach(this::pushToAllDevices); defaultProvider.init(deviceService); + store.existingRequests().forEach(this::pushToAllDevices); log.info("Started"); }