From f58185df4de4c8d7cb4710e96a1b7e204c9157cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6llner?= Date: Sun, 29 Dec 2019 23:03:14 +0100 Subject: [PATCH] Improved diagnostic output for hunting the mysterious spuriously failing TcpRpcStress.Embargo test --- Capnp.Net.Runtime.Tests/TcpRpcPorted.cs | 2 +- Capnp.Net.Runtime/Rpc/RefCountingCapability.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Capnp.Net.Runtime.Tests/TcpRpcPorted.cs b/Capnp.Net.Runtime.Tests/TcpRpcPorted.cs index 90b2b72..3402ce9 100644 --- a/Capnp.Net.Runtime.Tests/TcpRpcPorted.cs +++ b/Capnp.Net.Runtime.Tests/TcpRpcPorted.cs @@ -482,7 +482,7 @@ namespace Capnp.Net.Runtime.Tests bool flag = call0.Wait(MediumNonDbgTimeout); Assert.IsTrue(flag); } - catch (RpcException exception) when (exception.Message == "Cannot access a disposed object.") + catch (AggregateException exception) when (exception.InnerException is RpcException rpcException && rpcException.Message == "Cannot access a disposed object.") { Logger.Log(LogLevel.Information, $"Oops, object disposed. Counter = {cap.Count}, tx count = {client.SendCount}, rx count = {client.RecvCount}"); throw; diff --git a/Capnp.Net.Runtime/Rpc/RefCountingCapability.cs b/Capnp.Net.Runtime/Rpc/RefCountingCapability.cs index 16fb7fc..e60e3dc 100644 --- a/Capnp.Net.Runtime/Rpc/RefCountingCapability.cs +++ b/Capnp.Net.Runtime/Rpc/RefCountingCapability.cs @@ -72,7 +72,7 @@ namespace Capnp.Rpc { --_refCount; - throw new ObjectDisposedException(nameof(ConsumedCapability)); + throw new ObjectDisposedException(ToString(), "Attempted to add reference to capability which was already released"); } } } @@ -106,7 +106,7 @@ namespace Capnp.Rpc { if (_refCount <= 0) { - throw new ObjectDisposedException(nameof(ConsumedCapability), "Validation failed, capability is already disposed"); + throw new ObjectDisposedException(ToString(), "Validation failed, capability is already disposed"); } } }