Satish K
Committed by Gerrit Code Review

Bug Fix - Tunnel subsystem 1. After delete the tunnel and then query the tunnel …

…and call provider. Query will always return null. Null Pointer exception.
2. In Borrow Tunnel, Order relationship is added even if the there is no tunnel to borrow. Note only where tunnel manger do not initiate the tunnel creation through provider.
3. In ConsistancyMap when the key (the set) is empty still the map hold the key with empty list and never deleted. Memory leak.

Change-Id: Iff8ba662f4828324c0588a9dfc494a2b158bcfce
......@@ -93,8 +93,9 @@ public class TunnelManager
@Override
public void removeTunnel(TunnelId tunnelId) {
checkNotNull(tunnelId, TUNNNEL_ID_NULL);
store.deleteTunnel(tunnelId);
Tunnel tunnel = store.queryTunnel(tunnelId);
if (tunnel != null) {
store.deleteTunnel(tunnelId);
if (tunnel.providerId() != null) {
TunnelProvider provider = getProvider(tunnel.providerId());
if (provider != null) {
......@@ -108,6 +109,7 @@ public class TunnelManager
}
}
}
}
@Override
public void updateTunnel(Tunnel tunnel, Path path) {
......@@ -129,8 +131,9 @@ public class TunnelManager
@Override
public void removeTunnels(TunnelEndPoint src, TunnelEndPoint dst,
ProviderId producerName) {
store.deleteTunnel(src, dst, producerName);
Collection<Tunnel> setTunnels = store.queryTunnel(src, dst);
if (!setTunnels.isEmpty()) {
store.deleteTunnel(src, dst, producerName);
for (Tunnel tunnel : setTunnels) {
if (producerName != null
&& !tunnel.providerId().equals(producerName)) {
......@@ -150,12 +153,14 @@ public class TunnelManager
}
}
}
}
@Override
public void removeTunnels(TunnelEndPoint src, TunnelEndPoint dst, Type type,
ProviderId producerName) {
store.deleteTunnel(src, dst, type, producerName);
Collection<Tunnel> setTunnels = store.queryTunnel(src, dst);
if (!setTunnels.isEmpty()) {
store.deleteTunnel(src, dst, type, producerName);
for (Tunnel tunnel : setTunnels) {
if (producerName != null
&& !tunnel.providerId().equals(producerName)
......@@ -176,6 +181,7 @@ public class TunnelManager
}
}
}
}
@Override
public Tunnel borrowTunnel(ApplicationId consumerId, TunnelId tunnelId,
......