<commit_before>﻿using Microsoft.ServiceBus;
using Microsoft.ServiceBus.Messaging;
using Microsoft.WindowsAzure;
using System;

namespace RescueMe.Domain
{
    public class OutboundSmsMessageQueue
    {
        private const string SmsQueueName = "rescuemeoutboundsms";
        private const string SmsQueueConnectionStringKey = "RescueMe.Outbound.Queue.ConnectionString";

        private static volatile QueueClient _queue;
        private static readonly object _lock = new object();

        private static void InitializeQueue()
        {
            if (_queue == null)
            {
                lock (_lock)
                {
                    if (_queue == null)
                    {
                        string conn = CloudConfigurationManager.GetSetting(SmsQueueConnectionStringKey);

                        var namespaceManager = NamespaceManager.CreateFromConnectionString(conn);

                        if (!namespaceManager.QueueExists(SmsQueueName))
                        {
                            namespaceManager.CreateQueue(SmsQueueName);
                        }

                        _queue = QueueClient.CreateFromConnectionString(conn, SmsQueueName, ReceiveMode.PeekLock);
                    }
                }
            }
        }

        private static QueueClient Queue
        {
            get
            {
                InitializeQueue();
                return _queue;
            }
        }

        public static void Add(OutboundSmsMessage message)
        {
            BrokeredMessage queueMsg = new BrokeredMessage(message);
            queueMsg.ScheduledEnqueueTimeUtc = message.ScheduledTime.UtcDateTime;
            Queue.Send(queueMsg);
        }

        public static void ProcessNext(Action<OutboundSmsMessage> callback)
        {
            try
            {
                var message = Queue.Receive(TimeSpan.FromHours(1));
                var sms = message.GetBody<OutboundSmsMessage>();
                callback(sms);
                message.Complete();
            }
            catch (TimeoutException)
            {
                // the Receive timeout passed
                // just eat it and return
            }
        }
    }
}
<commit_msg>null check missing on queue receive<commit_after>﻿using Microsoft.ServiceBus;
using Microsoft.ServiceBus.Messaging;
using Microsoft.WindowsAzure;
using System;

namespace RescueMe.Domain
{
    public class OutboundSmsMessageQueue
    {
        private const string SmsQueueName = "rescuemeoutboundsms";
        private const string SmsQueueConnectionStringKey = "RescueMe.Outbound.Queue.ConnectionString";

        private static volatile QueueClient _queue;
        private static readonly object _lock = new object();

        private static void InitializeQueue()
        {
            if (_queue == null)
            {
                lock (_lock)
                {
                    if (_queue == null)
                    {
                        string conn = CloudConfigurationManager.GetSetting(SmsQueueConnectionStringKey);

                        var namespaceManager = NamespaceManager.CreateFromConnectionString(conn);

                        if (!namespaceManager.QueueExists(SmsQueueName))
                        {
                            namespaceManager.CreateQueue(SmsQueueName);
                        }

                        _queue = QueueClient.CreateFromConnectionString(conn, SmsQueueName, ReceiveMode.PeekLock);
                    }
                }
            }
        }

        private static QueueClient Queue
        {
            get
            {
                InitializeQueue();
                return _queue;
            }
        }

        public static void Add(OutboundSmsMessage message)
        {
            BrokeredMessage queueMsg = new BrokeredMessage(message);
            queueMsg.ScheduledEnqueueTimeUtc = message.ScheduledTime.UtcDateTime;
            Queue.Send(queueMsg);
        }

        public static void ProcessNext(Action<OutboundSmsMessage> callback)
        {
            try
            {
                var message = Queue.Receive(TimeSpan.FromHours(1));
                if (message != null)
                {
                    var sms = message.GetBody<OutboundSmsMessage>();
                    callback(sms);
                    message.Complete();
                }
            }
            catch (TimeoutException)
            {
                // the Receive timeout passed
                // just eat it and return
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.06522214926679798, 'fraction_numerical': 0.0004377325454147516, 'mean_word_length': 1.4205508474576272, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6876534', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1017, 'n_words': 218}