[BEAM-2989] Fixed error when using Void type in WithKeys.#3922
Closed
youngoli wants to merge 2 commits intoapache:masterfrom
Closed
[BEAM-2989] Fixed error when using Void type in WithKeys.#3922youngoli wants to merge 2 commits intoapache:masterfrom
youngoli wants to merge 2 commits intoapache:masterfrom
Conversation
Also added error messages to WithKeys.of and VoidCoder.encode.
Contributor
Author
|
R: @lukecwik |
lukecwik
reviewed
Sep 29, 2017
Member
lukecwik
left a comment
There was a problem hiding this comment.
Minor suggestions, LGTM once the edits are done.
| public void encode(Void value, OutputStream outStream) { | ||
| public void encode(Void value, OutputStream outStream) throws IOException { | ||
| if (value != null) { | ||
| throw (new IOException("Attempting to encode non-null value with VoidCoder.")); |
Member
There was a problem hiding this comment.
Drop extraneous brackets:
throw (new IOException("Attempting to encode non-null value with VoidCoder.")); -> throw new IOException("Attempting to encode non-null value with VoidCoder.");
| KV.of(100, "bbb") | ||
| ); | ||
|
|
||
| private static final List<KV<Void, String>> WITH_CONST_KEYS_NULL = Arrays.asList( |
Member
There was a problem hiding this comment.
WITH_CONST_KEYS_NULL -> WITH_CONST_NULL_KEYS
|
Changes Unknown when pulling ff6ba35 on youngoli:bug-2989 into ** on apache:master**. |
lukecwik
reviewed
Oct 3, 2017
|
|
||
| @Override | ||
| public void encode(Void value, OutputStream outStream) { | ||
| public void encode(Void value, OutputStream outStream) throws IOException { |
Member
There was a problem hiding this comment.
It turns out that we don't need this change since the case to the Void type should never work from an arbitrary user type. I remove this change and merged your code.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow this checklist to help us incorporate your contribution quickly and easily:
[BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replaceBEAM-XXXwith the appropriate JIRA issue.mvn clean verifyto make sure basic checks pass. A more thorough check will be performed on your pull request automatically.WithKeyshad trouble correctly getting aVoidCoderwhen called with a null input before. This fix makes it so that it now functions when the input is(Void) null. This is done by passing Void.class as the key's class type instead of null, if the inputted key was null. Note that a null input that isn't cast to Void calls theWithKeys.oftaking aSerializableFunctioninstead, so I added a precondition with a warning message to that one.Also added a unit test to confirm that the fix works as intended, a quick change to
VoidCoderto ensure that it doesn't get used inappropriately, and fixed a few warnings inWithKeysTest.