Fix Hash/Array fingerprint instability across JRuby versions#79
Fix Hash/Array fingerprint instability across JRuby versions#79donoghuc merged 3 commits intologstash-plugins:mainfrom
Conversation
JRuby 10 changed Hash#inspect spacing, producing different fingerprint bytes for nested Hash/Array fields. Use a pipe-delimited format instead of relying on Hash#inspect.
In practice this would only appply to complex ruby objects. I would imagine in practice most of the actual use case are for string values. While this change will change the sha for some complex objects, that "duplication" risk is one off. Trying to keep full behavior compatability would inevitably produce a messy and brittle solution that is likely not worth it. |
andsel
left a comment
There was a problem hiding this comment.
The general idea sounds good, I've left a doubt.
| when Array | ||
| object.map { |e| to_canonical_string(e) }.join("|") | ||
| else | ||
| object |
There was a problem hiding this comment.
Shouldn't return a string in case of Object?
| object | |
| object.to_s |
There was a problem hiding this comment.
My fault for the confusing name. We actually dont want to always produce a string (for example the hash of an integer 1 would be different than the string "1". I updated the helper name to avoid the inconsistency, but we dont want the .to_s here.
This commit renames the function to normalize objects. We dont actually need "string" values generally as the old name suggests.
JRuby 10 changed Hash#inspect spacing, producing different fingerprint bytes for nested Hash/Array fields. Use a pipe-delimited format instead of relying on Hash#inspect.
Thanks for contributing to Logstash! If you haven't already signed our CLA, here's a handy link: https://www.elastic.co/contributor-agreement/
Closes: #78