From 2e22369ce04c5bbcace26b711b21cb0694701d62 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Fri, 15 Nov 2019 23:12:17 +0000 Subject: [PATCH] set flag before submitting to threadpool --- core/src/main/groovy/com/muwire/core/chat/ChatClient.groovy | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 11f86588..70e5f2d6 100644 --- a/core/src/main/groovy/com/muwire/core/chat/ChatClient.groovy +++ b/core/src/main/groovy/com/muwire/core/chat/ChatClient.groovy @@ -1,5 +1,6 @@ package com.muwire.core.chat +import java.lang.System.Logger.Level import java.nio.charset.StandardCharsets import java.util.concurrent.Executor import java.util.concurrent.Executors @@ -46,11 +47,11 @@ class ChatClient implements Closeable { void connectIfNeeded() { if (connection != null || connectInProgress || (System.currentTimeMillis() - lastRejectionTime < REJECTION_BACKOFF)) return + connectInProgress = true CONNECTOR.execute({connect()}) } private void connect() { - connectInProgress = true connectThread = Thread.currentThread() Endpoint endpoint = null try { @@ -94,6 +95,7 @@ class ChatClient implements Closeable { eventBus.publish(new ChatConnectionEvent(status : ChatConnectionAttemptStatus.SUCCESSFUL, persona : host, connection : connection)) } catch (Exception e) { + log.log(java.util.logging.Level.WARNING, "connect failed", e) eventBus.publish(new ChatConnectionEvent(status : ChatConnectionAttemptStatus.FAILED, persona : host)) if (endpoint != null) { try {endpoint.getOutputStream().close() } catch (IOException ignore) {}