Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Fixed two issues regarding BufferCleanPayload #295

Merged
merged 1 commit into from
Nov 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public async Task<SentPayloadResult> SendPayloadAsync(List<string> payload, bool
{
var cleanPayload = new List<string>();
var invalidPayload = GetInvalidPayloadAsync(response, payload, out cleanPayload);
if ((cleanPayload?.Any() == false) && first)
if ((cleanPayload?.Any() ?? false) && first)
{
await SendPayloadAsync(cleanPayload, false);
}
Expand Down Expand Up @@ -96,20 +96,22 @@ private InvalidResult GetInvalidPayloadAsync(DynamicResponse baseResult, List<st
hasErrors = true;
var id = itemIndex?["_id"];
var error = itemIndex?["error"];
var errorString = $"type: {error?["type"] ?? "Unknown"}, reason: {error?["reason"] ?? "Unknown"}";

if (int.TryParse(id.Split('_')[0], out int index))
{
SelfLog.WriteLine("Received failed ElasticSearch shipping result {0}: {1}. Failed payload : {2}.", status, error?.ToString(), payload.ElementAt(index * 2 + 1));
SelfLog.WriteLine("Received failed ElasticSearch shipping result {0}: {1}. Failed payload : {2}.", status, errorString, payload.ElementAt(index * 2 + 1));
badPayload.Add(payload.ElementAt(index * 2));
badPayload.Add(payload.ElementAt(index * 2 + 1));
if (_cleanPayload != null)
{
cleanPayload.Add(payload.ElementAt(index * 2));
cleanPayload.Add(_cleanPayload(payload.ElementAt(index * 2 + 1), status, error?.ToString()));
cleanPayload.Add(_cleanPayload(payload.ElementAt(index * 2 + 1), status, errorString));
}
}
else
{
SelfLog.WriteLine($"Received failed ElasticSearch shipping result {status}: {error?.ToString()}.");
SelfLog.WriteLine($"Received failed ElasticSearch shipping result {status}: {errorString}.");
}
}

Expand Down