for (Tunnel tunnel : tunnels) {
try {
ByteArrayWriter msg = new ByteArrayWriter();
msg.writeInt(tunnel.getResourceId());
if (!agent.sendRequest(new Request(STOP_LOCAL_TUNNEL, msg.toByteArray()), false) && e == null) {
e = new TunnelException(TunnelException.AGENT_REFUSED_LOCAL_TUNNEL_STOP, (Throwable)null);
}
} catch (IOException ex) {
throw new TunnelException(TunnelException.INTERNAL_ERROR, ex);
}