Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport PR #16760 to 8.17: ensure inputSize state value is reset during buftok.flush #16770

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Dec 9, 2024

Backport PR #16760 to 8.17 branch, original message:


The BufferedTokenizer.flush must reset the inputSize value back to zero on flush, otherwise it will grow until a buffer full exception is thrown if the buffer has a size limit.

We can see the test fails if the inputSize = 0 is not present:

❯ bin/rspec logstash-core/spec/logstash/util/buftok_spec.rb -fd -e flush
[...]
FileWatch::BufferedTokenizer
  flush
    emits the contents of the buffer
    resets the state of the buffer
    with decode_size_limit_bytes
      resets the state of the buffer (FAILED - 1)
      emits the contents of the buffer

Failures:

  1) FileWatch::BufferedTokenizer flush with decode_size_limit_bytes resets the state of the buffer
     Failure/Error: expect(subject).to be_empty
       expected `#<FileWatch::BufferedTokenizer:0x35977ba7>.empty?` to be truthy, got false
     # ./logstash-core/spec/logstash/util/buftok_spec.rb:65:in `block in <main>'
     # ./spec/spec_helper.rb:84:in `block in <main>'

But with it tests pass:

❯ bin/rspec logstash-core/spec/logstash/util/buftok_spec.rb -fd -e flush

FileWatch::BufferedTokenizer
  flush
    resets the state of the buffer
    emits the contents of the buffer
    with decode_size_limit_bytes
      emits the contents of the buffer
      resets the state of the buffer

Finished in 0.0246 seconds (files took 1.34 seconds to load)
4 examples, 0 failures

Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

Copy link
Member

@donoghuc donoghuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean backport, green CI.

@donoghuc donoghuc merged commit 33ac279 into 8.17 Dec 9, 2024
5 checks passed
@donoghuc donoghuc deleted the backport_16760_8.17 branch December 9, 2024 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants