Small fix to the http tunnel to prevent null pointer is attempt is made to close channel twice

This commit is contained in:
Jamie Furness 2011-07-01 16:55:41 +01:00 committed by Trustin Lee
parent ccc155e96f
commit 8982838ab2

View File

@ -163,6 +163,15 @@ class ServerMessageSwitch implements ServerMessageSwitchUpstreamInterface,
@Override
public void clientCloseTunnel(String tunnelId) {
TunnelInfo tunnel = tunnelsById.get(tunnelId);
if (tunnel == null) {
if (LOG.isWarnEnabled()) {
LOG.warn("attempt made to close tunnel id " +
tunnelId + " which is unknown or closed");
}
return;
}
tunnel.localChannel.clientClosed();
tunnelsById.remove(tunnelId);
}
@ -170,6 +179,15 @@ class ServerMessageSwitch implements ServerMessageSwitchUpstreamInterface,
@Override
public void serverCloseTunnel(String tunnelId) {
TunnelInfo tunnel = tunnelsById.get(tunnelId);
if (tunnel == null) {
if (LOG.isWarnEnabled()) {
LOG.warn("attempt made to close tunnel id " +
tunnelId + " which is unknown or closed");
}
return;
}
tunnel.closing.set(true);
Channel responseChannel = tunnel.responseChannel.getAndSet(null);