StreamError error = new StreamError(doc);
// Close the connection
socket.close();
socket = null;
// throw the exception with the wrapped error
throw new ComponentException(error);
}
// Everything went fine
// Start keep alive thread to send every 30 seconds of inactivity a heart beat
keepAliveTask = new KeepAliveTask();
TaskEngine.getInstance().scheduleAtFixedRate(keepAliveTask, 15000, 30000);
timeoutTask = new TimeoutTask();
TaskEngine.getInstance().scheduleAtFixedRate(timeoutTask, 2000, 2000);
} catch (DocumentException e) {
try {
socket.close();
}
catch (IOException ioe) {
// Do nothing
}
throw new ComponentException(e);
} catch (XmlPullParserException e) {
try {
socket.close();
}
catch (IOException ioe) {
// Do nothing
}
throw new ComponentException(e);
}
} catch (XmlPullParserException e) {
try {
socket.close();
}
catch (IOException ioe) {
// Do nothing
}
throw new ComponentException(e);
}
}
catch (UnknownHostException uhe) {
try {
if (socket != null) socket.close();
}
catch (IOException e) {
// Do nothing
}
throw new ComponentException(uhe);
}
catch (IOException ioe) {
try {
if (socket != null) socket.close();
}
catch (IOException e) {
// Do nothing
}
throw new ComponentException(ioe);
}
}