Committed by
Pavlin Radoslavov
Fix for ONOS-393 - NPE when one of the devices can no longer be found
[Merged from master] Change-Id: I5c907d8124585f9af5b3f6e7315c41cbcdd03fb9 (cherry picked from commit f2695400)
Showing
1 changed file
with
7 additions
and
3 deletions
| ... | @@ -29,6 +29,7 @@ import org.apache.felix.scr.annotations.Service; | ... | @@ -29,6 +29,7 @@ import org.apache.felix.scr.annotations.Service; |
| 29 | import org.onosproject.event.AbstractListenerRegistry; | 29 | import org.onosproject.event.AbstractListenerRegistry; |
| 30 | import org.onosproject.event.EventDeliveryService; | 30 | import org.onosproject.event.EventDeliveryService; |
| 31 | import org.onosproject.net.ConnectPoint; | 31 | import org.onosproject.net.ConnectPoint; |
| 32 | +import org.onosproject.net.Device; | ||
| 32 | import org.onosproject.net.DeviceId; | 33 | import org.onosproject.net.DeviceId; |
| 33 | import org.onosproject.net.Link; | 34 | import org.onosproject.net.Link; |
| 34 | import org.onosproject.net.Link.State; | 35 | import org.onosproject.net.Link.State; |
| ... | @@ -273,9 +274,12 @@ public class LinkManager | ... | @@ -273,9 +274,12 @@ public class LinkManager |
| 273 | // Removes all links in the specified set and emits appropriate events. | 274 | // Removes all links in the specified set and emits appropriate events. |
| 274 | private void removeLinks(Set<Link> links, boolean isSoftRemove) { | 275 | private void removeLinks(Set<Link> links, boolean isSoftRemove) { |
| 275 | for (Link link : links) { | 276 | for (Link link : links) { |
| 276 | - if (!deviceService.getDevice(link.src().deviceId()).type().equals( | 277 | + final Device srcDevice = deviceService.getDevice(link.src().deviceId()); |
| 277 | - deviceService.getDevice(link.dst().deviceId()).type())) { | 278 | + final Device dstDevice = deviceService.getDevice(link.dst().deviceId()); |
| 278 | - //TODO this is aweful. need to be fixed so that we don't down | 279 | + if (srcDevice != null && |
| 280 | + dstDevice != null && | ||
| 281 | + !srcDevice.type().equals(dstDevice.type())) { | ||
| 282 | + //TODO this is awful. need to be fixed so that we don't down | ||
| 279 | // configured links. perhaps add a mechanism to figure out the | 283 | // configured links. perhaps add a mechanism to figure out the |
| 280 | // state of this link | 284 | // state of this link |
| 281 | log.info("Ignoring removal of link as device types are " + | 285 | log.info("Ignoring removal of link as device types are " + | ... | ... |
-
Please register or login to post a comment