Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
fix(logsender): do not log SocktException when manually closing LogSe…
Browse files Browse the repository at this point in the history
…nderHandler (#1183)
  • Loading branch information
itsaky committed Aug 7, 2023
1 parent ce1ab73 commit 4d8a6a2
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class LogSenderHandler(
internal var onClose: (String) -> Unit = {}
) : Thread("LogSenderHandler"), AutoCloseable {

private var manuallyClosed = false
private val log = ILogger.newInstance("LogSenderHandler")

override fun run() {
Expand All @@ -45,18 +46,24 @@ class LogSenderHandler(
LogLine.forLogString(reader.readLine())?.let { line -> consumer?.invoke(line) }
} catch (interrupt: InterruptedException) {
currentThread().interrupt()
break
}
}
}
} catch (err: SocketException) {
log.error("An error occurred while reading from socket", err)
log.error("An error occurred while reading from socket")
if (!manuallyClosed) {
log.error(err)
}
} finally {
close()
}
}

override fun close() {
try {
manuallyClosed = true

if (!socket.isClosed) {
log.debug("Closing log sender handler...")
socket.close()
Expand Down

0 comments on commit 4d8a6a2

Please sign in to comment.