From 7ea1c5dd1db35ad4cca6f7fec1295f85667706c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6llner?= Date: Fri, 23 Aug 2019 22:53:49 +0200 Subject: [PATCH] RpcEngine.RemoveImport should throw rather than just log a warning when import ID is wrong --- Capnp.Net.Runtime.Tests/TcpRpcInterop.cs | 2 +- Capnp.Net.Runtime/Rpc/RpcEngine.cs | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Capnp.Net.Runtime.Tests/TcpRpcInterop.cs b/Capnp.Net.Runtime.Tests/TcpRpcInterop.cs index 0d283f3..051da1f 100644 --- a/Capnp.Net.Runtime.Tests/TcpRpcInterop.cs +++ b/Capnp.Net.Runtime.Tests/TcpRpcInterop.cs @@ -345,7 +345,7 @@ namespace Capnp.Net.Runtime.Tests })); } - // Ensure that all answers either return (probably in canceled state) + // Ensure that all answers return (probably in canceled state) Assert.IsTrue(Task.WhenAll(taskList).Wait(LargeNonDbgTimeout)); // Not part of original test. "Terminate" sequence with diff --git a/Capnp.Net.Runtime/Rpc/RpcEngine.cs b/Capnp.Net.Runtime/Rpc/RpcEngine.cs index be864fe..f114197 100644 --- a/Capnp.Net.Runtime/Rpc/RpcEngine.cs +++ b/Capnp.Net.Runtime/Rpc/RpcEngine.cs @@ -1453,16 +1453,12 @@ namespace Capnp.Rpc void IRpcEndpoint.RemoveImport(uint importId) { - bool exists; - lock (_reentrancyBlocker) { - exists = _importTable.Remove(importId); - } - - if (!exists) - { - Logger.LogError("Inconsistent import table detected"); + if (!_importTable.Remove(importId)) + { + throw new ArgumentException("Given ID does not exist in import table"); + } } }