Backport PR #16968 to 8.17: Fix BufferedTokenizer to properly resume after a buffer full condition respecting the encoding of the input string #17022
+426
−13
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.
Backport PR #16968 to 8.17 branch, original message:
Release notes
[rn:skip]
What does this PR do?
This is a second take to fix the processing of tokens from the tokenizer after a buffer full error. The first try #16482 was rollbacked to the encoding error #16694.
The first try failed on returning the tokens in the same encoding of the input.
This PR does a couple of things:
concat
method instead ofaddAll
, which avoid to convert RubyString to String and back to RubyString. When return the headStringBuilder
it enforce the encoding with the input charset.Why is it important/What is the impact to the user?
Permit to use effectively the tokenizer also in context where a line is bigger than a limit.
Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files (and/or docker env variables)Author's Checklist
How to test this PR locally
The test plan has two sides:
How to test the encoding is respected
Startup a REPL with Logstash and exercise the tokenizer:
or use the following script
with the Logstash run as
bin/logstash -e "input { tcp { port => 1234 codec => line { charset => 'ISO8859-1' } } } output { stdout { codec => rubydebug } }"
In the output the
£
as to be present and not£
Related issues
BufferedTokenizerExt
#16694