Jonathan Hart

Null checking in packet-out mechanism.

If the switch has recently disconnected, we can get some NullPointerExceptions.

Change-Id: Ia5a854ed5cd6a933974c855e7297faa542626d9e
......@@ -97,7 +97,13 @@ implements PacketService, PacketProviderRegistry {
private void localEmit(OutboundPacket packet) {
final Device device = deviceService.getDevice(packet.sendThrough());
if (device == null) {
return;
}
final PacketProvider packetProvider = getProvider(device.providerId());
if (packetProvider != null) {
packetProvider.emit(packet);
}
......
......@@ -95,6 +95,10 @@ public class DistributedPacketStore
NodeId myId = clusterService.getLocalNode().id();
NodeId master = mastershipService.getMasterFor(packet.sendThrough());
if (master == null) {
return;
}
if (myId.equals(master)) {
notifyDelegate(new PacketEvent(Type.EMIT, packet));
return;
......