GUAC-906: Implement GuacamoleConnectionClosedException. Throw when read/write fails due to closure.

This commit is contained in:
Michael Jumper
2014-10-26 15:14:35 -07:00
parent 721d9125ab
commit b83c83c324
8 changed files with 140 additions and 10 deletions

View File

@@ -25,9 +25,11 @@ package org.glyptodon.guacamole.io;
import java.io.IOException;
import java.io.Reader;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.util.Deque;
import java.util.LinkedList;
import org.glyptodon.guacamole.GuacamoleConnectionClosedException;
import org.glyptodon.guacamole.GuacamoleException;
import org.glyptodon.guacamole.GuacamoleServerException;
import org.glyptodon.guacamole.GuacamoleUpstreamTimeoutException;
@@ -182,6 +184,9 @@ public class ReaderGuacamoleReader implements GuacamoleReader {
catch (SocketTimeoutException e) {
throw new GuacamoleUpstreamTimeoutException("Connection to guacd timed out.", e);
}
catch (SocketException e) {
throw new GuacamoleConnectionClosedException("Connection to guacd is closed.", e);
}
catch (IOException e) {
throw new GuacamoleServerException(e);
}

View File

@@ -25,8 +25,12 @@ package org.glyptodon.guacamole.io;
import java.io.IOException;
import java.io.Writer;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import org.glyptodon.guacamole.GuacamoleConnectionClosedException;
import org.glyptodon.guacamole.GuacamoleException;
import org.glyptodon.guacamole.GuacamoleServerException;
import org.glyptodon.guacamole.GuacamoleUpstreamTimeoutException;
import org.glyptodon.guacamole.protocol.GuacamoleInstruction;
/**
@@ -58,6 +62,12 @@ public class WriterGuacamoleWriter implements GuacamoleWriter {
output.write(chunk, off, len);
output.flush();
}
catch (SocketTimeoutException e) {
throw new GuacamoleUpstreamTimeoutException("Connection to guacd timed out.", e);
}
catch (SocketException e) {
throw new GuacamoleConnectionClosedException("Connection to guacd is closed.", e);
}
catch (IOException e) {
throw new GuacamoleServerException(e);
}