From 12afd2d74861d910b752c2a94575b7f610afffe0 Mon Sep 17 00:00:00 2001 From: Carol Wang Date: Thu, 2 Nov 2023 06:52:29 +0000 Subject: [PATCH] Catch unhandled exception when closing connection. --- .../src/System/ServiceModel/Channels/ConnectionPool.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/System.ServiceModel.NetFramingBase/src/System/ServiceModel/Channels/ConnectionPool.cs b/src/System.ServiceModel.NetFramingBase/src/System/ServiceModel/Channels/ConnectionPool.cs index 5c96473ddad..7904bf97b60 100644 --- a/src/System.ServiceModel.NetFramingBase/src/System/ServiceModel/Channels/ConnectionPool.cs +++ b/src/System.ServiceModel.NetFramingBase/src/System/ServiceModel/Channels/ConnectionPool.cs @@ -632,9 +632,13 @@ protected override void AbortItem(IConnection item) item.Abort(); } - protected override ValueTask CloseItemAsync(IConnection item, TimeSpan timeout) + protected override async ValueTask CloseItemAsync(IConnection item, TimeSpan timeout) { - return item.CloseAsync(timeout); + try + { + await item.CloseAsync(timeout); + } + catch (Exception) { } } public virtual bool IsCompatible(IConnectionOrientedTransportChannelFactorySettings settings)