From 28b5ca20f052a4e5e9aedd0deaf68050d51991e9 Mon Sep 17 00:00:00 2001 From: Rafael Lillo Date: Wed, 23 Jul 2025 23:03:34 +0100 Subject: [PATCH] fix: NullReference with outbox sweeper --- src/Paramore.Brighter/IAmAnOutbox.cs | 2 +- src/Paramore.Brighter/OutboxProducerMediator.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Paramore.Brighter/IAmAnOutbox.cs b/src/Paramore.Brighter/IAmAnOutbox.cs index cecd433e02..55666ff4bc 100644 --- a/src/Paramore.Brighter/IAmAnOutbox.cs +++ b/src/Paramore.Brighter/IAmAnOutbox.cs @@ -15,6 +15,6 @@ public interface IAmAnOutbox /// We inject this so that we can use the same tracer as the calling application /// You do not need to set this property as we will set it when setting up the External Service Bus /// - IAmABrighterTracer Tracer { set; } + IAmABrighterTracer? Tracer { set; } } } diff --git a/src/Paramore.Brighter/OutboxProducerMediator.cs b/src/Paramore.Brighter/OutboxProducerMediator.cs index cd1df04c12..27c881069c 100644 --- a/src/Paramore.Brighter/OutboxProducerMediator.cs +++ b/src/Paramore.Brighter/OutboxProducerMediator.cs @@ -80,7 +80,7 @@ public partial class OutboxProducerMediator : IAmAnOutbo private readonly int _maxOutStandingMessages; private readonly TimeSpan _maxOutStandingCheckInterval; private readonly Dictionary _outBoxBag; - private readonly IAmABrighterTracer _tracer; + private readonly IAmABrighterTracer? _tracer; private readonly TimeProvider _timeProvider; /// @@ -107,7 +107,7 @@ public OutboxProducerMediator( IAmAMessageMapperRegistry mapperRegistry, IAmAMessageTransformerFactory messageTransformerFactory, IAmAMessageTransformerFactoryAsync messageTransformerFactoryAsync, - IAmABrighterTracer tracer, + IAmABrighterTracer? tracer, IAmAPublicationFinder publicationFinder, IAmAnOutbox? outbox = null, IAmARequestContextFactory? requestContextFactory = null, @@ -603,7 +603,7 @@ CancellationToken cancellationToken await s_clearSemaphoreToken.WaitAsync(cancellationToken); var parentSpan = requestContext.Span; - var span = _tracer.CreateClearSpan(CommandProcessorSpanOperation.Clear, requestContext.Span, null, + var span = _tracer?.CreateClearSpan(CommandProcessorSpanOperation.Clear, requestContext.Span, null, _instrumentationOptions); try { @@ -640,7 +640,7 @@ CancellationToken cancellationToken } finally { - _tracer.EndSpan(span); + _tracer?.EndSpan(span); s_clearSemaphoreToken.Release(); s_backgroundClearSemaphoreToken.Release(); }