Fix varying responses for <index>/_analyze request #44342
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently we loose information about whether a token list in an AnalyzeAction
response is null or an empty list, because we write a 0 value to the stream in
both cases and deserialize to a null value on the receiving side. This was fixed
in #44284 by a change in the serialization protocol starting in 7.3. However
this PR fixes the symptoms without changing the wire protocol which we cannot to
easily on 6.8 because we already released incompatible versions in the 7.x line.
This change adds special handling on xcontent output and if getToken() is
callled on either AnalyzeResponse or DetailedAnalyzeResponse to always return
empty lists instead of null values.
Relates to #44078