Skip to content

Commit f0fc35d

Browse files
author
Sophia Tevosyan
committed
fixed a typo, added an argument range check for the max dispatch count
1 parent eecc077 commit f0fc35d

4 files changed

Lines changed: 22 additions & 1 deletion

File tree

src/DurableTask.Core/TaskActivityDispatcher.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ internal TaskActivityDispatcher(
6767
this.logHelper = logHelper;
6868
this.errorPropagationMode = errorPropagationMode;
6969
this.exceptionPropertiesProvider = exceptionPropertiesProvider;
70+
71+
if (maxDispatchCount <= 0)
72+
{
73+
throw new ArgumentOutOfRangeException(nameof(maxDispatchCount), "The maximum dispatch count must be greater than 0");
74+
}
7075
this.maxDispatchCount = maxDispatchCount;
7176

7277
this.dispatcher = new WorkItemDispatcher<TaskActivityWorkItem>(
@@ -193,7 +198,7 @@ async Task OnProcessWorkItemAsync(TaskActivityWorkItem workItem)
193198
if (scheduledEvent.DispatchCount > this.maxDispatchCount || scheduledEvent.IsPoisoned)
194199
{
195200
string message = scheduledEvent.IsPoisoned
196-
? "Activity worker has recenved an event that does not specify an Activity name"
201+
? "Activity worker has received an event that does not specify an Activity name"
197202
: $"Activity worker has received an event with dispatch count {taskMessage.Event.DispatchCount} which exceeds " +
198203
$"the maximum dispatch count of {this.maxDispatchCount}";
199204

src/DurableTask.Core/TaskEntityDispatcher.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ internal TaskEntityDispatcher(
7676
this.exceptionPropertiesProvider = exceptionPropertiesProvider;
7777
this.entityOrchestrationService = (orchestrationService as IEntityOrchestrationService)!;
7878
this.entityBackendProperties = entityOrchestrationService.EntityBackendProperties;
79+
80+
if (maxDispatchCount <= 0)
81+
{
82+
throw new ArgumentOutOfRangeException(nameof(maxDispatchCount), "The maximum dispatch count must be greater than 0");
83+
}
7984
this.maxDispatchCount = maxDispatchCount;
8085

8186
this.dispatcher = new WorkItemDispatcher<TaskOrchestrationWorkItem>(

src/DurableTask.Core/TaskHubWorker.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ public TaskHubWorker(
250250
this.logHelper = new LogHelper(loggerFactory?.CreateLogger("DurableTask.Core"));
251251
this.dispatchEntitiesSeparately = (orchestrationService as IEntityOrchestrationService)?.EntityBackendProperties?.UseSeparateQueueForEntityWorkItems ?? false;
252252
this.versioningSettings = versioningSettings;
253+
254+
if (maxDispatchCount <= 0)
255+
{
256+
throw new ArgumentOutOfRangeException(nameof(maxDispatchCount), "The maximum dispatch count must be greater than 0");
257+
}
253258
this.maxDispatchCount = maxDispatchCount;
254259
}
255260

src/DurableTask.Core/TaskOrchestrationDispatcher.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,14 @@ internal TaskOrchestrationDispatcher(
8686
this.entityParameters = TaskOrchestrationEntityParameters.FromEntityBackendProperties(this.entityBackendProperties);
8787
this.versioningSettings = versioningSettings;
8888
this.exceptionPropertiesProvider = exceptionPropertiesProvider;
89+
90+
if (maxDispatchCount <= 0)
91+
{
92+
throw new ArgumentOutOfRangeException(nameof(maxDispatchCount), "The maximum dispatch count must be greater than 0");
93+
}
8994
this.maxDispatchCount = maxDispatchCount;
9095

96+
9197
this.dispatcher = new WorkItemDispatcher<TaskOrchestrationWorkItem>(
9298
"TaskOrchestrationDispatcher",
9399
item => item == null ? string.Empty : item.InstanceId,

0 commit comments

Comments
 (0)