Skip to content

Commit

Permalink
Make sure that non-serializable ComponentActivatorException doesn't b…
Browse files Browse the repository at this point in the history
…reak the middleware pipeline.
  • Loading branch information
yallie committed Dec 4, 2024
1 parent fb8b97a commit c39b901
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CoreRemoting.Tests/RpcTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ public void Failing_component_constructor_throws_RemoteInvocationException()
ConnectionTimeout = 3,
InvocationTimeout = 3,
SendTimeout = 3,
Channel = ClientChannel,
MessageEncryption = false,
ServerPort = _serverFixture.Server.Config.NetworkPort,
});
Expand All @@ -549,7 +550,7 @@ public void Failing_component_constructor_throws_RemoteInvocationException()
var ex = Assert.Throws<RemoteInvocationException>(() => proxy.Hello());

Assert.NotNull(ex);
Assert.Contains(ex.Message, "IFailingService");
Assert.Contains("FailingService", ex.Message);
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion CoreRemoting/RemotingSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ private void ProcessRpcMessage(WireMessage request)
serverRpcContext.Exception =
new RemoteInvocationException(
message: ex.Message,
innerEx: ex.GetType().IsSerializable ? ex : null);
innerEx: ex.ToSerializable());

if (oneWay)
return;
Expand Down
6 changes: 5 additions & 1 deletion CoreRemoting/Serialization/ExceptionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Castle.MicroKernel.ComponentActivator;
using System;
using System.Linq;

namespace CoreRemoting.Serialization;
Expand All @@ -20,6 +21,9 @@ public static class ExceptionExtensions
agg.InnerException.IsSerializable() &&
agg.GetType().IsSerializable,

// pesky exception that looks like serializable but really isn't
ComponentActivatorException cax => false,

_ => ex.GetType().IsSerializable &&
ex.InnerException.IsSerializable()
};
Expand Down

0 comments on commit c39b901

Please sign in to comment.