Skip to content

HttpEventCollectorSender FlushAsync task is not started and thus cannot be awaited unless manually started #51

Description

@seanmarthur

I believe the FlushAsync method is implemented incorrectly:

https://github.com/splunk/splunk-library-dotnetlogging/blob/master/src/Splunk.Logging.Common/HttpEventCollectorSender.cs#L292-L298

There are examples on the web (see here) showing the usage as:

await ecSender.FlushAsync();

However, when trying to run such a sample, the application hangs forever at this line. This is because the underling task never starts. The proper usage as the code currently is would be:

var flushTask = ecSender.FlushAsync();
flushTask.Start();
await flushTask;

However the consumer should not need to start this task manually - it should be returned from FlushAsync in a started state.

Refactored FlushAsync example:

    public Task FlushAsync()
    {
      var task = new Task(() =>
     {
       FlushSync();
     });
      task.Start();
      return task;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions