<commit_before>namespace NServiceBus
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Pipeline;
    using Routing;
    using Transport;

    class RetrySuccessNotificationBehavior : Behavior<IIncomingPhysicalMessageContext>
    {
        public RetrySuccessNotificationBehavior(string endpointName, string notificationAddress, string[] triggerHeaders, bool copyBody)
        {
            this.endpointName = endpointName;
            this.notificationAddress = notificationAddress;
            this.triggerHeaders = triggerHeaders;
            this.copyBody = copyBody;
        }

        public override async Task Invoke(IIncomingPhysicalMessageContext context, Func<Task> next)
        {
            await next().ConfigureAwait(false);

            if (!context.MessageHeaders.Keys.Intersect(triggerHeaders).Any())
            {
                return;
            }

            var processedMessage = new OutgoingMessage(context.MessageId, new Dictionary<string, string>(context.Message.Headers), copyBody ? context.Message.Body : new byte[0]);

            processedMessage.Headers.Add(Headers.ProcessingEndpoint, endpointName);

            var operations = context.Extensions.Get<PendingTransportOperations>();

            operations.Add(new TransportOperation(processedMessage, new UnicastAddressTag(notificationAddress)));
        }

        readonly string endpointName;
        readonly string notificationAddress;<commit_msg>Do not add header if it already exists<commit_after>namespace NServiceBus
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Pipeline;
    using Routing;
    using Transport;

    class RetrySuccessNotificationBehavior : Behavior<IIncomingPhysicalMessageContext>
    {
        public RetrySuccessNotificationBehavior(string endpointName, string notificationAddress, string[] triggerHeaders, bool copyBody)
        {
            this.endpointName = endpointName;
            this.notificationAddress = notificationAddress;
            this.triggerHeaders = triggerHeaders;
            this.copyBody = copyBody;
        }

        public override async Task Invoke(IIncomingPhysicalMessageContext context, Func<Task> next)
        {
            await next().ConfigureAwait(false);

            if (!context.MessageHeaders.Keys.Intersect(triggerHeaders).Any())
            {
                return;
            }

            var processedMessage = new OutgoingMessage(context.MessageId, new Dictionary<string, string>(context.Message.Headers), copyBody ? context.Message.Body : new byte[0]);

            if (!processedMessage.Headers.ContainsKey(Headers.ProcessingEndpoint))
            {
                processedMessage.Headers.Add(Headers.ProcessingEndpoint, endpointName);
            }

            var operations = context.Extensions.Get<PendingTransportOperations>();

            operations.Add(new TransportOperation(processedMessage, new UnicastAddressTag(notificationAddress)));
        }

        readonly string endpointName;
        readonly string notificationAddress;
{'fraction_non_alphanumeric': 0.07503152585119799, 'fraction_numerical': 0.0006305170239596469, 'mean_word_length': 2.8554070473876063, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3315252', 'n_tokens_mistral': 733, 'n_tokens_neox': 713, 'n_words': 158}