Null checking in packet-out mechanism.
If the switch has recently disconnected, we can get some NullPointerExceptions. Change-Id: Ia5a854ed5cd6a933974c855e7297faa542626d9e
Showing
2 changed files
with
10 additions
and
0 deletions
... | @@ -97,7 +97,13 @@ implements PacketService, PacketProviderRegistry { | ... | @@ -97,7 +97,13 @@ implements PacketService, PacketProviderRegistry { |
97 | 97 | ||
98 | private void localEmit(OutboundPacket packet) { | 98 | private void localEmit(OutboundPacket packet) { |
99 | final Device device = deviceService.getDevice(packet.sendThrough()); | 99 | final Device device = deviceService.getDevice(packet.sendThrough()); |
100 | + | ||
101 | + if (device == null) { | ||
102 | + return; | ||
103 | + } | ||
104 | + | ||
100 | final PacketProvider packetProvider = getProvider(device.providerId()); | 105 | final PacketProvider packetProvider = getProvider(device.providerId()); |
106 | + | ||
101 | if (packetProvider != null) { | 107 | if (packetProvider != null) { |
102 | packetProvider.emit(packet); | 108 | packetProvider.emit(packet); |
103 | } | 109 | } | ... | ... |
... | @@ -95,6 +95,10 @@ public class DistributedPacketStore | ... | @@ -95,6 +95,10 @@ public class DistributedPacketStore |
95 | NodeId myId = clusterService.getLocalNode().id(); | 95 | NodeId myId = clusterService.getLocalNode().id(); |
96 | NodeId master = mastershipService.getMasterFor(packet.sendThrough()); | 96 | NodeId master = mastershipService.getMasterFor(packet.sendThrough()); |
97 | 97 | ||
98 | + if (master == null) { | ||
99 | + return; | ||
100 | + } | ||
101 | + | ||
98 | if (myId.equals(master)) { | 102 | if (myId.equals(master)) { |
99 | notifyDelegate(new PacketEvent(Type.EMIT, packet)); | 103 | notifyDelegate(new PacketEvent(Type.EMIT, packet)); |
100 | return; | 104 | return; | ... | ... |
-
Please register or login to post a comment