-
Notifications
You must be signed in to change notification settings - Fork 505
METRON-614: Eliminate use of the default Charset #1341
Conversation
|
+1 by inspection. Thanks! |
|
I noticed that your work removes all DefaultCharset warnings from Error Prone. Yay! Can we turn on the error level setting for that check, so that if anyone accidentally re-introduces this the build will fail? I think the following change to pom.xml will do that. |
|
@nickwallen That change is already included in the pom https://github.com/apache/metron/pull/1341/files#diff-600376dffeb79835ede4a0b285078036R248 |
|
Ah, very good. +1 Thanks for addressing this. |
|
Hey @justinleet - Can you clean-up the conflicts when you get a chance? |
|
I like this PR - aside from the conflicts is there anything left to resolve? |
|
Fixed the conflicts and ran back up in full dev. Having said that, I'd like to hold off on merging this until the release is over, since I don't want to try to change something like this or work around it if something comes up. |
|
@mmiklavc @nickwallen @ottobackwards I merged master post-release and ran up in full dev again. Is everyone still good with the changes? |
|
Probably worth referencing this - https://lists.apache.org/thread.html/55e57410cb8cd467a51545e4ae0f9f67d32312cc3f9e1afa144552f4@%3Cdev.metron.apache.org%3E Just to follow up - are there any concerns with, for example, non-UTF-8 inbound data charsets? I think it makes sense for us to normalize, however we may run into trouble in our parsers, e.g https://github.com/apache/metron/pull/1341/files#diff-e5a5c182fb529e5e2d93fc9f06ce1012. |
|
Ahh good call, it's been long enough that I'd forgotten about that discussion. There should definitely at least be a README addition that I'll add. Re: non-UTF-8 inbound data sets, that's potentially a fair problem, although I don't personally know what the circumstances would be where non-UTF-8 string data is coming from (maybe Latin-1?). Seems like the only real way to deal with this is to make it configurable at the parser level, or otherwise mixing incoming charset encodings is a problem (Which I think it would be right now, if everything is just using platform default, right? Double check my thinking on that). Then the parser itself just reads with whatever character encoding. At that point, stuff like say GrokParser would need do something like |
|
I think setting a default to In general, I agree that it would be odd for any network sensors to be set to anything other than |
What is the status of this? I assume the suggestion here to provide additional configuration is a feature enhancement request and not something we would tackle on this PR. Is that right @mmiklavc? What do we need to do to get this PR merged? |
I thought this could be handled pretty trivially here. What if we modified this ever so slightly to include a default charset for the parsers that can be overridden as needed? Here's an example. We could even push that config option into the BasicParser if we wanted. The upshot is that this seems like a really trivial change. Rather than opening another PR to address it, can we just add the option with our desired default now and be done with it? |
|
I think that is reasonable, but I would want to see tests with alternate charsets |
e.g. test that we can read in ISO-8859-1 and properly convert to UTF-8? Yeah, that makes sense. @justinleet I'm happy to work on that and submit a PR against your PR. I think we just need some conflict resolution before I tackle that. |
|
@mmiklavc Sure, I'll deconflict and get you set up. Definitely would appreciate the help; I've been too busy to come back to this and that's not gonna clear up for a couple weeks at least. |
Bump - any chance you can deconflict this @justinleet? Again, I'm happy to contribute the parser changes discussed above, but I need a clean PR to work from. |
|
@mmiklavc I'll try to get to it by the end of the week. I had a personal emergency come up last week, and unfortunately this fell pretty hard in my personal priorities. Sorry about the delay on it |
|
@mmiklavc Merged in master, fixed the incoming issues that would have caused problems, built successfully, and ran up full dev and made sure data flowed through. |
|
Apparently I built skipping tests, I'll take a look when I have a chance |
|
Thanks @justinleet! I'll take a look at this again. |
|
fyi, I'm also seeing this failing unit test |
|
@mmiklavc I merged in your PR against this branch. I'll add any commentary here as I review, but obviously feel encouraged to run through anything you want on here. |
justinleet
left a comment
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.
@mmiklavc Couple review comments, as a heads up
.../metron-parsers-common/src/main/java/org/apache/metron/parsers/interfaces/MessageParser.java
Show resolved
Hide resolved
...-parsing/metron-parsers-common/src/main/java/org/apache/metron/parsers/ParserRunnerImpl.java
Outdated
Show resolved
Hide resolved
...arsing/metron-parsers-common/src/main/java/org/apache/metron/parsers/json/JSONMapParser.java
Outdated
Show resolved
Hide resolved
|
The PR from @mmiklavc (justinleet#22) got merged to address the couple |
|
@mmiklavc Unit test looks like it fails because a mocked parser NPEs on the |
|
Well that's odd - apparently our version of Mockito doesn't call the provided concrete method for default interface methods. Submitting another fix now. |
|
Merged. Adds some docs and the test fix. @mmiklavc Assuming the build succeeds, are we good for @nickwallen + @ottobackwards to follow up on their reviews? |
|
Ran this up in full-dev, everything seems to be working. Ship it. +1 |
|
@mmiklavc We should probably add a note to the Upgrading.md. There is a backwards compatibility concern when upgrading: When a current user's default Charset is not UTF_8, they'll need to update their parser configs to use the appropriate one, or parsing will run into issues. |
|
I assume you mean if they were using the system default, which is Java's default when a charset is not provided when converting from bytearray to String? Just to be clear, this is an upgrade concern based off the fundamental nature of this PR change as a whole, not specifically the specific parser configs. |
|
@mmiklavc If they're using a system default that isn't UTF-8 (say ISO_8859_1), all the parsers that currently work would silently start using the new default of UTF-8 and no longer be able to parse the data. Let me know if this understanding is incorrect. For most, if not all, users this shouldn't be a concern, but I just want to make sure it's communicated. The specific parser configs are what enables us to fix this case (by updating parsers), and the change as a whole is what potentially causes it. |
|
That is correct @justinleet |
|
@mmiklavc I've added an upgrading note. Let me know if I'm missing anything there. As a reminder to whoever merges this in (admittedly probably me), it'll be important to manually squash the commits in order to maintain attribution for both Mike and myself. |
|
lgtm. I'm a non-binding +1 (due to my contributions to the PR). |
|
@nickwallen anything you need to see before we wrap up this PR? |
|
No, I am good. Thanks for all the hard work. Please proceed. |
|
Just confirming, are you still +1 @ottobackwards with the recent Upgrading.md changes? |
|
yup, let's get it out |
Contributor Comments
Most of the motivation here is to spur discussion about what we want to do. I changed everything to UTF-8. Because UTF-8 is usually a solid default.
Everything with default charset now uses
StandardCharsets.UTF_8(with the occasional variant ofStandardCharsets.UTF_8.name()).I've done a few things here
PrintStream,FileReader, andFileWriter.**
PrintStreamjust requires modifying the args slightly (need to includeautoFlushin params).**
FileReaderandFileWriterdo not accept encoding arguments and are drop in replaced with variants that do."".getBytes()that were in our tests.As a nice side effect, the build logs are cleaner now that error prone isn't squawking on every default charset.
Pull Request Checklist
Thank you for submitting a contribution to Apache Metron.
Please refer to our Development Guidelines for the complete guide to follow for contributions.
Please refer also to our Build Verification Guidelines for complete smoke testing guides.
In order to streamline the review of the contribution we ask you follow these guidelines and ask you to double check the following:
For all changes:
For code changes:
Have you included steps to reproduce the behavior or problem that is being changed or addressed?
Have you included steps or a guide to how the change may be verified and tested manually?
Have you ensured that the full suite of tests and checks have been executed in the root metron folder via:
Have you written or updated unit tests and or integration tests to verify your changes?
If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
Have you verified the basic functionality of the build by building and running locally with Vagrant full-dev environment or the equivalent?
For documentation related changes:
Have you ensured that format looks appropriate for the output in which it is rendered by building and verifying the site-book? If not then run the following commands and the verify changes via
site-book/target/site/index.html:Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
It is also recommended that travis-ci is set up for your personal repository such that your branches are built there before submitting a pull request.