From 6b804aa1bf0a334c0538025301e0a7a4fbcda6a1 Mon Sep 17 00:00:00 2001 From: Luke Bakken Date: Sun, 10 Dec 2023 20:44:32 -0800 Subject: [PATCH] Follow-up to #1434 The original change in #1438 introduced a breaking API change, reported here: https://github.com/addupsolutions/AddUp.FakeRabbitMQ/pull/189 --- .../client/api/ShutdownEventArgs.cs | 16 ++++++++++++---- .../RabbitMQ.Client/client/impl/Connection.cs | 6 +++--- projects/Unit/APIApproval.Approve.verified.txt | 5 +++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/projects/RabbitMQ.Client/client/api/ShutdownEventArgs.cs b/projects/RabbitMQ.Client/client/api/ShutdownEventArgs.cs index 961c4a74ed..2aa672227d 100644 --- a/projects/RabbitMQ.Client/client/api/ShutdownEventArgs.cs +++ b/projects/RabbitMQ.Client/client/api/ShutdownEventArgs.cs @@ -47,8 +47,8 @@ public class ShutdownEventArgs : EventArgs /// Construct a with the given parameters and /// 0 for and . /// - public ShutdownEventArgs(ShutdownInitiator initiator, ushort replyCode, string replyText, object cause = null, Exception exception = null) - : this(initiator, replyCode, replyText, 0, 0, cause, exception) + public ShutdownEventArgs(ShutdownInitiator initiator, ushort replyCode, string replyText, object cause = null) + : this(initiator, replyCode, replyText, 0, 0, cause) { } @@ -56,7 +56,7 @@ public ShutdownEventArgs(ShutdownInitiator initiator, ushort replyCode, string r /// Construct a with the given parameters. /// public ShutdownEventArgs(ShutdownInitiator initiator, ushort replyCode, string replyText, - ushort classId, ushort methodId, object cause = null, Exception exception = null) + ushort classId, ushort methodId, object cause = null) { Initiator = initiator; ReplyCode = replyCode; @@ -64,7 +64,15 @@ public ShutdownEventArgs(ShutdownInitiator initiator, ushort replyCode, string r ClassId = classId; MethodId = methodId; Cause = cause; - _exception = exception; + } + + /// + /// Construct a with the given parameters. + /// + public ShutdownEventArgs(ShutdownInitiator initiator, ushort replyCode, string replyText, Exception exception) + : this(initiator, replyCode, replyText, 0, 0) + { + _exception = exception ?? throw new ArgumentNullException(nameof(exception)); } /// diff --git a/projects/RabbitMQ.Client/client/impl/Connection.cs b/projects/RabbitMQ.Client/client/impl/Connection.cs index 19d105c899..477baa7910 100644 --- a/projects/RabbitMQ.Client/client/impl/Connection.cs +++ b/projects/RabbitMQ.Client/client/impl/Connection.cs @@ -543,7 +543,7 @@ public void MainLoop() // Possible heartbeat exception var ea = new ShutdownEventArgs(ShutdownInitiator.Library, 0, "End of stream", - cause: null, exception: eose); + exception: eose); HandleMainLoopException(ea); } catch (HardProtocolException hpe) @@ -558,7 +558,7 @@ public void MainLoop() */ var ea = new ShutdownEventArgs(ShutdownInitiator.Library, Constants.InternalError, fileLoadException.Message, - cause: null, exception: fileLoadException); + exception: fileLoadException); HandleMainLoopException(ea); } catch (Exception ex) @@ -566,7 +566,7 @@ public void MainLoop() var ea = new ShutdownEventArgs(ShutdownInitiator.Library, Constants.InternalError, $"Unexpected Exception: {ex.Message}", - cause: null, exception: ex); + exception: ex); HandleMainLoopException(ea); } diff --git a/projects/Unit/APIApproval.Approve.verified.txt b/projects/Unit/APIApproval.Approve.verified.txt index fdfda01b15..c67881833a 100644 --- a/projects/Unit/APIApproval.Approve.verified.txt +++ b/projects/Unit/APIApproval.Approve.verified.txt @@ -609,8 +609,9 @@ namespace RabbitMQ.Client } public class ShutdownEventArgs : System.EventArgs { - public ShutdownEventArgs(RabbitMQ.Client.ShutdownInitiator initiator, ushort replyCode, string replyText, object cause = null, System.Exception exception = null) { } - public ShutdownEventArgs(RabbitMQ.Client.ShutdownInitiator initiator, ushort replyCode, string replyText, ushort classId, ushort methodId, object cause = null, System.Exception exception = null) { } + public ShutdownEventArgs(RabbitMQ.Client.ShutdownInitiator initiator, ushort replyCode, string replyText, System.Exception exception) { } + public ShutdownEventArgs(RabbitMQ.Client.ShutdownInitiator initiator, ushort replyCode, string replyText, object cause = null) { } + public ShutdownEventArgs(RabbitMQ.Client.ShutdownInitiator initiator, ushort replyCode, string replyText, ushort classId, ushort methodId, object cause = null) { } public object Cause { get; } public ushort ClassId { get; } public System.Exception Exception { get; }