From 6bd125ef22c418e12387a04038679976b2ef9efb Mon Sep 17 00:00:00 2001 From: Erlend Hamnaberg Date: Mon, 26 Feb 2024 13:45:22 +0100 Subject: [PATCH] Hardening of unregistering the http4s handler --- .../org/http4s/netty/client/Http4sChannelPoolMap.scala | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/src/main/scala/org/http4s/netty/client/Http4sChannelPoolMap.scala b/client/src/main/scala/org/http4s/netty/client/Http4sChannelPoolMap.scala index 7cf528dd..86cc0268 100644 --- a/client/src/main/scala/org/http4s/netty/client/Http4sChannelPoolMap.scala +++ b/client/src/main/scala/org/http4s/netty/client/Http4sChannelPoolMap.scala @@ -119,7 +119,15 @@ private[client] class Http4sChannelPoolMap[F[_]]( } } { h => val pipeline = channel.pipeline() - F.delay(if (pipeline.toMap.containsKey("http4s")) void(pipeline.remove(h)) else ()) + F.delay { + if (pipeline.toMap.containsKey("http4s")) + try + void(pipeline.remove(h)) + catch { + case _: Throwable => () + } + else () + } } response <- handler.dispatch(request, channel, key) } yield response