diff --git a/core/src/main/groovy/com/muwire/core/chat/ChatClient.groovy b/core/src/main/groovy/com/muwire/core/chat/ChatClient.groovy index e77fc180..11f86588 100644 --- a/core/src/main/groovy/com/muwire/core/chat/ChatClient.groovy +++ b/core/src/main/groovy/com/muwire/core/chat/ChatClient.groovy @@ -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 diff --git a/core/src/main/groovy/com/muwire/core/chat/ChatConnection.groovy b/core/src/main/groovy/com/muwire/core/chat/ChatConnection.groovy index d55ffa72..e79348e0 100644 --- a/core/src/main/groovy/com/muwire/core/chat/ChatConnection.groovy +++ b/core/src/main/groovy/com/muwire/core/chat/ChatConnection.groovy @@ -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() } }