-
Notifications
You must be signed in to change notification settings - Fork 57
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
Fix default codec instantiation #68
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tsaarni why default
nil
assigment and then thenil
(as if nil is a special value placeholder constant) instead of using the same path suggested in https://github.com/elastic/logstash/pull/11401/files which was listed in the issue you reported (elastic/logstash#11434) ?Assigning the codec to
nil
to then change itregister
time is not a good practice.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used
nil
as a special value placeholder in attempt to avoid class identity comparison altogether. Comparing class identity by their string representation seemed bit awkward to me, but I'm happy with any fix as long as it works! :)There already is a string-based alternative submitted here few years back but for some reason it was not merged #55. If the original submitter @jsvd is around maybe he could reconsider resurrecting the PR, or I can re-submit his fix here and add him as co-author.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW: What I really wanted to do was to set the
default :codec
toLogStash::Codecs::Plain.new({ "format" => @message })
but I could not achieve that, because obviously I have no access to instance variable@message
when defining default codec for the class. If that was possible, it would be possible to avoid instantiating codec inregister
like introduced here long time ago 2c73283 (change which introduced the class identity comparison).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you run tests on actual main, it fails for that check. To get the test back to green the string comparison works fine like in #65 which is why also this PR is green.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why PR #55 wasn't merged, but seems the right way to fix it. May in some weeks @jsvd could confirm it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I did not understand, #65 has failed because of the codec problem as well. Maybe you meant #55? I agree, string comparing works, I'm happy if we get that in!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad sorry, #69
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsvd confirmed that the #55 was closed for some other reason, mainly because the Travis CI changes were already included.