Skip to content

Commit

Permalink
Add job notification ObjectDisposedException handling (#4682)
Browse files Browse the repository at this point in the history
* added object disposed handling for notifications

* Fix build issue / unneded import

* undo api changes

* minimized change impact to export

* simplified notification publishing

* fix typos
  • Loading branch information
mikaelweave authored Oct 24, 2024
1 parent a39a73c commit 5bb52a6
Showing 1 changed file with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,31 @@ private async Task CompleteJobAsync(OperationStatus completionStatus, Cancellati
dataSize,
isAnonymizedExport);

await _mediator.Publish(new ExportTaskMetricsNotification(_exportJobRecord), CancellationToken.None);
try
{
await _mediator.Publish(new ExportTaskMetricsNotification(_exportJobRecord), cancellationToken);
}
catch (ObjectDisposedException ode)
{
if (cancellationToken.IsCancellationRequested)
{
_logger.LogWarning(ode, $"{nameof(ObjectDisposedException)}. Unable to publish {nameof(ExportTaskMetricsNotification)}. Cancellation was requested.");
}
else
{
_logger.LogCritical(ode, $"{nameof(ObjectDisposedException)}. Unable to publish {nameof(ExportTaskMetricsNotification)}.");
throw;
}
}
catch (OperationCanceledException oce)
{
_logger.LogWarning(oce, $"{nameof(OperationCanceledException)}. Unable to publish {nameof(ExportTaskMetricsNotification)}. Cancellation was requested.");
}
catch (Exception ex)
{
_logger.LogCritical(ex, $"Unable to publish {nameof(ExportTaskMetricsNotification)}.");
throw;
}
}

private async Task UpdateJobRecordAsync(CancellationToken cancellationToken)
Expand Down

0 comments on commit 5bb52a6

Please sign in to comment.