+ (tunnel.getSourceInterface() == null || tunnel.getSourceInterface().equals("") ? "" : tunnel
.getSourceInterface());
remoteTunnel = tunnels.get(tunnelId);
if (remoteTunnel != null) {
if (remoteTunnel.getAgent() == agent) {
throw new TunnelException(TunnelException.REMOTE_TUNNEL_IN_USE, (Throwable)null, String.valueOf(tunnel.getSourcePort()));
}
throw new TunnelException(TunnelException.REMOTE_TUNNEL_LOCKED, (Throwable)null, String.valueOf(tunnel.getSourcePort()));
}
try {
remoteTunnel = new RemoteTunnel(tunnel, agent, this, launchSession);
agent.addListener(new RemoteTunnelListener(remoteTunnel));
if (log.isInfoEnabled())
log.info("Adding remote tunnel with id of " + tunnelId);
List<RemoteTunnel> sessionTunnels = tunnelsBySession.get(agent.getSession().getId());
if (sessionTunnels == null) {
sessionTunnels = new ArrayList<RemoteTunnel>();
tunnelsBySession.put(agent.getSession().getId(), sessionTunnels);
}
sessionTunnels.add(remoteTunnel);
tunnels.put(tunnelId, remoteTunnel);
} catch (IOException e) {
log.error("Failed to create new remote tunnel.", e);
throw new TunnelException(TunnelException.PORT_ALREADY_IN_USE, (Throwable)null, String.valueOf(tunnel.getSourcePort()));
}
}
return remoteTunnel;
}