Add logging for exceptions within websocket tunnel servlets.

This commit is contained in:
Michael Jumper
2013-10-16 10:02:34 -07:00
parent 2db11ea489
commit 8481254273
2 changed files with 17 additions and 9 deletions

View File

@@ -27,6 +27,8 @@ import org.glyptodon.guacamole.net.GuacamoleTunnel;
import org.eclipse.jetty.websocket.WebSocket; import org.eclipse.jetty.websocket.WebSocket;
import org.eclipse.jetty.websocket.WebSocket.Connection; import org.eclipse.jetty.websocket.WebSocket.Connection;
import org.eclipse.jetty.websocket.WebSocketServlet; import org.eclipse.jetty.websocket.WebSocketServlet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* A WebSocketServlet partial re-implementation of GuacamoleTunnelServlet. * A WebSocketServlet partial re-implementation of GuacamoleTunnelServlet.
@@ -35,6 +37,11 @@ import org.eclipse.jetty.websocket.WebSocketServlet;
*/ */
public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet { public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet {
/**
* Logger for this class.
*/
private static Logger logger = LoggerFactory.getLogger(GuacamoleWebSocketTunnelServlet.class);
/** /**
* The default, minimum buffer size for instructions. * The default, minimum buffer size for instructions.
*/ */
@@ -50,7 +57,8 @@ public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet {
tunnel = doConnect(request); tunnel = doConnect(request);
} }
catch (GuacamoleException e) { catch (GuacamoleException e) {
return null; // FIXME: Can throw exception? logger.error("Error connecting WebSocket tunnel.", e);
return null;
} }
// Return new WebSocket which communicates through tunnel // Return new WebSocket which communicates through tunnel
@@ -65,7 +73,7 @@ public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet {
writer.write(string.toCharArray()); writer.write(string.toCharArray());
} }
catch (GuacamoleException e) { catch (GuacamoleException e) {
// FIXME: Handle exception logger.debug("Tunnel write failed.", e);
} }
tunnel.releaseWriter(); tunnel.releaseWriter();
@@ -98,10 +106,10 @@ public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet {
} }
} }
catch (IOException e) { catch (IOException e) {
// FIXME: Handle exception logger.debug("Tunnel read failed due to I/O error.", e);
} }
catch (GuacamoleException e) { catch (GuacamoleException e) {
// FIXME: Handle exception logger.debug("Tunnel read failed.", e);
} }
} }
@@ -118,7 +126,7 @@ public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet {
tunnel.close(); tunnel.close();
} }
catch (GuacamoleException e) { catch (GuacamoleException e) {
// FIXME: Handle exception logger.debug("Unable to close WebSocket tunnel.", e);
} }
} }

View File

@@ -83,7 +83,7 @@ public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet {
} }
catch (GuacamoleException e) { catch (GuacamoleException e) {
// FIXME: Handle exception logger.debug("Tunnel write failed.", e);
} }
tunnel.releaseWriter(); tunnel.releaseWriter();
@@ -127,10 +127,10 @@ public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet {
} }
} }
catch (IOException e) { catch (IOException e) {
// FIXME: Handle exception logger.debug("Tunnel read failed due to I/O error.", e);
} }
catch (GuacamoleException e) { catch (GuacamoleException e) {
// FIXME: Handle exception logger.debug("Tunnel read failed.", e);
} }
} }
@@ -147,7 +147,7 @@ public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet {
tunnel.close(); tunnel.close();
} }
catch (GuacamoleException e) { catch (GuacamoleException e) {
// FIXME: Handle exception logger.debug("Unable to close WebSocket tunnel.", e);
} }
} }