Skip to content

Commit

Permalink
GH-1604 Mute subscriber that tries to write to closed output (#1607)
Browse files Browse the repository at this point in the history
* Added error catching as asked for in issue #1604

* Added error catching as asked for in issue #1604 Also Imported ClosedChannelException

* Codestyle

Co-authored-by: dzikoysk <dzikoysk@dzikoysk.net>
  • Loading branch information
P-DR0ZD and dzikoysk committed Oct 15, 2022
1 parent 40aeca7 commit cfd0665
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import io.javalin.websocket.WsContext
import io.javalin.websocket.WsMessageContext
import panda.std.Result
import panda.std.reactive.Reference
import java.nio.channels.ClosedChannelException
import java.util.WeakHashMap
import java.util.function.Consumer

Expand Down Expand Up @@ -66,7 +67,11 @@ internal class CliEndpoint(
journalist.logger.info("CLI | $identifier accessed remote console")

val subscriberId = journalist.subscribe {
ctx.send(it.value)
try {
ctx.send(it.value)
} catch (ignored: ClosedChannelException) {
journalist.logger.debug("CLI | $identifier tried to write to closed channel")
}
}

users[ctx] = WsSession(identifier, subscriberId)
Expand Down

0 comments on commit cfd0665

Please sign in to comment.