Committed by
Gerrit Code Review
Fixed a potential NPE in link discovery.
Change-Id: I3bff307e54a1e3bdac1053dfea6e96ae3cd29f07
Showing
1 changed file
with
6 additions
and
1 deletions
| ... | @@ -40,6 +40,7 @@ import org.slf4j.Logger; | ... | @@ -40,6 +40,7 @@ import org.slf4j.Logger; |
| 40 | import java.nio.ByteBuffer; | 40 | import java.nio.ByteBuffer; |
| 41 | import java.util.Set; | 41 | import java.util.Set; |
| 42 | 42 | ||
| 43 | +import static com.google.common.base.Strings.isNullOrEmpty; | ||
| 43 | import static java.util.concurrent.TimeUnit.MILLISECONDS; | 44 | import static java.util.concurrent.TimeUnit.MILLISECONDS; |
| 44 | import static org.onosproject.net.PortNumber.portNumber; | 45 | import static org.onosproject.net.PortNumber.portNumber; |
| 45 | import static org.onosproject.net.flow.DefaultTrafficTreatment.builder; | 46 | import static org.onosproject.net.flow.DefaultTrafficTreatment.builder; |
| ... | @@ -165,7 +166,10 @@ public class LinkDiscovery implements TimerTask { | ... | @@ -165,7 +166,10 @@ public class LinkDiscovery implements TimerTask { |
| 165 | 166 | ||
| 166 | PortNumber srcPort = portNumber(onoslldp.getPort()); | 167 | PortNumber srcPort = portNumber(onoslldp.getPort()); |
| 167 | PortNumber dstPort = packetContext.inPacket().receivedFrom().port(); | 168 | PortNumber dstPort = packetContext.inPacket().receivedFrom().port(); |
| 168 | - DeviceId srcDeviceId = DeviceId.deviceId(onoslldp.getDeviceString()); | 169 | + |
| 170 | + String idString = onoslldp.getDeviceString(); | ||
| 171 | + if (!isNullOrEmpty(idString)) { | ||
| 172 | + DeviceId srcDeviceId = DeviceId.deviceId(idString); | ||
| 169 | DeviceId dstDeviceId = packetContext.inPacket().receivedFrom().deviceId(); | 173 | DeviceId dstDeviceId = packetContext.inPacket().receivedFrom().deviceId(); |
| 170 | 174 | ||
| 171 | ConnectPoint src = new ConnectPoint(srcDeviceId, srcPort); | 175 | ConnectPoint src = new ConnectPoint(srcDeviceId, srcPort); |
| ... | @@ -180,6 +184,7 @@ public class LinkDiscovery implements TimerTask { | ... | @@ -180,6 +184,7 @@ public class LinkDiscovery implements TimerTask { |
| 180 | } | 184 | } |
| 181 | return true; | 185 | return true; |
| 182 | } | 186 | } |
| 187 | + } | ||
| 183 | return false; | 188 | return false; |
| 184 | } | 189 | } |
| 185 | 190 | ... | ... |
-
Please register or login to post a comment