diff --git a/sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/src/Listeners/ServiceBusTargetScaler.cs b/sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/src/Listeners/ServiceBusTargetScaler.cs index ea2246b62149e..eda2f1092df9c 100644 --- a/sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/src/Listeners/ServiceBusTargetScaler.cs +++ b/sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/src/Listeners/ServiceBusTargetScaler.cs @@ -94,17 +94,7 @@ internal TargetScalerResult GetScaleResultInternal(TargetScalerContext context, throw new ArgumentOutOfRangeException($"Unexpected concurrency='{concurrency}' - the value must be > 0."); } - int targetWorkerCount; - - try - { - targetWorkerCount = (int)Math.Ceiling(messageCount / (decimal)concurrency); - } - catch (OverflowException) - { - targetWorkerCount = int.MaxValue; - } - + int targetWorkerCount = (int)Math.Ceiling(messageCount / (decimal)concurrency); _logger.LogInformation($"Target worker count for function '{_functionId}' is '{targetWorkerCount}' (EntityPath='{_entityPath}', MessageCount ='{messageCount}', Concurrency='{concurrency}')."); return new TargetScalerResult diff --git a/sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/tests/Listeners/ServiceBusTargetScalerTests.cs b/sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/tests/Listeners/ServiceBusTargetScalerTests.cs index e749def9f9613..567d5a5e975af 100644 --- a/sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/tests/Listeners/ServiceBusTargetScalerTests.cs +++ b/sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/tests/Listeners/ServiceBusTargetScalerTests.cs @@ -27,10 +27,7 @@ public void Setup() [TestCase(100, true, true, null, 4)] [TestCase(100, false, true, 19, 6)] [TestCase(100, false, false, null, 3)] - [TestCase(100, false, false, null, 3)] - [TestCase(2147483650, false, false, 1, 2147483647)] // cap targetWorkerCount at int.MaxValue - [TestCase(2147483650, false, false, 2, 1073741825)] - public void ServiceBusTargetScaler_Returns_Expected(long messageCount, bool isSessionEnabled, bool singleDispatch, int? concurrency, int expected) + public void ServiceBusTargetScaler_Returns_Expected(int messageCount, bool isSessionEnabled, bool singleDispatch, int? concurrency,int expected) { ServiceBusOptions options = new ServiceBusOptions {