flush outputstream on chat connect failures or rejections

This commit is contained in:
Zlatin Balevsky
2019-11-15 21:52:35 +00:00
parent 8fb015acbf
commit 15c59b440f
2 changed files with 7 additions and 1 deletions

View File

@ -72,6 +72,7 @@ class ChatClient implements Closeable {
if (code == 429) {
eventBus.publish(new ChatConnectionEvent(status : ChatConnectionAttemptStatus.REJECTED, persona : host))
try { dos.close() } catch (IOException ignore) {}
endpoint.close()
lastRejectionTime = System.currentTimeMillis()
return
@ -94,7 +95,10 @@ class ChatClient implements Closeable {
connection : connection))
} catch (Exception e) {
eventBus.publish(new ChatConnectionEvent(status : ChatConnectionAttemptStatus.FAILED, persona : host))
endpoint?.close()
if (endpoint != null) {
try {endpoint.getOutputStream().close() } catch (IOException ignore) {}
endpoint.close()
}
} finally {
connectInProgress = false
connectThread = null

View File

@ -109,6 +109,7 @@ class ChatConnection implements ChatLink {
} catch (Exception e) {
log.log(Level.WARNING,"unhandled exception in reader", e)
} finally {
try {endpoint.getOutputStream().close()} catch (IOException ignore) {}
close()
}
}
@ -123,6 +124,7 @@ class ChatConnection implements ChatLink {
} catch (Exception e) {
log.log(Level.WARNING,"unhandled exception in writer",e)
} finally {
try {endpoint.getOutputStream().close()} catch (IOException ignore) {}
close()
}
}