Skip to content

Commit

Permalink
Fix NullReferenceException in ExecutingWorkItemsTracker (#4850)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReubenBond authored and benjaminpetit committed Aug 16, 2018
1 parent fecad95 commit d1b87c7
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/Orleans.Core/Threading/ThreadPoolExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,11 @@ public ThreadPoolExecutor(
this.schedulerStatistics = schedulerStatistics;
this.schedulerStageStatistics = schedulerStageStatistics;
this.statisticsOptions = statisticsOptions;

workQueue = new ThreadPoolWorkQueue();

statistic = new ThreadPoolTrackingStatistic(options.Name, options.LoggerFactory, statisticsOptions, schedulerStageStatistics);

executingWorkTracker = new ExecutingWorkItemsTracker(this);

log = options.LoggerFactory.CreateLogger<ThreadPoolExecutor>();

this.workQueue = new ThreadPoolWorkQueue();
this.statistic = new ThreadPoolTrackingStatistic(options.Name, options.LoggerFactory, statisticsOptions, schedulerStageStatistics);
this.log = options.LoggerFactory.CreateLogger<ThreadPoolExecutor>();
this.executingWorkTracker = new ExecutingWorkItemsTracker(options, this.log);

options.CancellationTokenSource.Token.Register(Complete);

for (var threadIndex = 0; threadIndex < options.DegreeOfParallelism; threadIndex++)
Expand Down Expand Up @@ -214,10 +210,11 @@ private sealed class ExecutingWorkItemsTracker : ExecutionActionFilter

private readonly ILogger log;

public ExecutingWorkItemsTracker(ThreadPoolExecutor executor)
public ExecutingWorkItemsTracker(ThreadPoolExecutorOptions options, ILogger log)
{
runningItems = new WorkItem[GetThreadSlot(executor.options.DegreeOfParallelism)];
log = executor.log;
if (options == null) throw new ArgumentNullException(nameof(options));
this.runningItems = new WorkItem[GetThreadSlot(options.DegreeOfParallelism)];
this.log = log ?? throw new ArgumentNullException(nameof(log));
}

public override void OnActionExecuting(ExecutionContext context)
Expand All @@ -238,7 +235,7 @@ public bool HasFrozenWork()
if (workItem != null && workItem.IsFrozen())
{
frozen = true;
log.Error(
this.log.Error(
ErrorCode.ExecutorTurnTooLong,
string.Format(SR.WorkItem_LongExecutionTime, workItem.GetWorkItemStatus(true)));
}
Expand Down

0 comments on commit d1b87c7

Please sign in to comment.