commit | e538711b8dcb6dbe317af50c4e46836aeb04d6b3 | [log] [tgz] |
---|---|---|
author | Jonathan Hart <jono@onlab.us> | Thu Feb 02 13:22:31 2017 -0800 |
committer | Jonathan Hart <jono@onlab.us> | Fri Feb 03 17:52:10 2017 +0000 |
tree | c0cd7e35f53e2576d7ce1814af93213e981be6b5 | |
parent | 9df5bc64eb0a0499420a0a0370ec0f73660e862e [diff] |
Prevent NoSuchElementException if no hosts are found Change-Id: I7c2b95fda87ca1281e99e1771c88dfd6967db8fd
diff --git a/apps/routing/common/src/main/java/org/onosproject/routing/impl/BgpSpeakerNeighbourHandler.java b/apps/routing/common/src/main/java/org/onosproject/routing/impl/BgpSpeakerNeighbourHandler.java index 4ebaac2..b98b69a 100644 --- a/apps/routing/common/src/main/java/org/onosproject/routing/impl/BgpSpeakerNeighbourHandler.java +++ b/apps/routing/common/src/main/java/org/onosproject/routing/impl/BgpSpeakerNeighbourHandler.java
@@ -154,13 +154,14 @@ case REPLY: // Proxy replies over to our internal BGP speaker if the host // is known to us - Host h = hostService.getHostsByMac(context.dstMac()).stream() - .findFirst() - .get(); - if (h == null) { + Set<Host> hosts = hostService.getHostsByMac(context.dstMac()); + + if (hosts.isEmpty()) { context.drop(); } else { + Host h = hosts.stream().findFirst().get(); VlanId bgpSpeakerVlanId = h.vlan(); + if (!bgpSpeakerVlanId.equals(VlanId.NONE)) { context.packet().setVlanID(bgpSpeakerVlanId.toShort()); } else {