-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix json deserialize byte to string bug #8140
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
Merged
Merged
+147
−10
Conversation
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
/pulsarbot run-failure-checks |
Thanks for the fix. Could you please add a test for that? |
@zymap Thanks for you feedback. I will add the test. |
I have add the test, please take a look, thanks. @sijie @codelipenghui @jiazhai @zymap |
/pulsarbot run-failure-checks |
sijie
approved these changes
Oct 2, 2020
wolfstudy
pushed a commit
that referenced
this pull request
Oct 30, 2020
Fix #7657 ### Motivation In `GenericJsonRecord.java`, it deserialize byte to String. ``` public Object getField(String fieldName) { JsonNode fn = jn.get(fieldName); if (fn.isContainerNode()) { AtomicInteger idx = new AtomicInteger(0); List<Field> fields = Lists.newArrayList(fn.fieldNames()) .stream() .map(f -> new Field(f, idx.getAndIncrement())) .collect(Collectors.toList()); return new GenericJsonRecord(schemaVersion, fields, fn); } else if (fn.isBoolean()) { return fn.asBoolean(); } else if (fn.isFloatingPointNumber()) { return fn.asDouble(); } else if (fn.isBigInteger()) { if (fn.canConvertToLong()) { return fn.asLong(); } else { return fn.asText(); } } else if (fn.isNumber()) { return fn.numberValue(); } else { return fn.asText(); } } ``` ### Changes Add check the jsonNode binary type and convert to binaryValue instead of `asText`. (cherry picked from commit 66c3733)
huangdx0726
pushed a commit
to huangdx0726/pulsar
that referenced
this pull request
Nov 13, 2020
Fix apache#7657 ### Motivation In `GenericJsonRecord.java`, it deserialize byte to String. ``` public Object getField(String fieldName) { JsonNode fn = jn.get(fieldName); if (fn.isContainerNode()) { AtomicInteger idx = new AtomicInteger(0); List<Field> fields = Lists.newArrayList(fn.fieldNames()) .stream() .map(f -> new Field(f, idx.getAndIncrement())) .collect(Collectors.toList()); return new GenericJsonRecord(schemaVersion, fields, fn); } else if (fn.isBoolean()) { return fn.asBoolean(); } else if (fn.isFloatingPointNumber()) { return fn.asDouble(); } else if (fn.isBigInteger()) { if (fn.canConvertToLong()) { return fn.asLong(); } else { return fn.asText(); } } else if (fn.isNumber()) { return fn.numberValue(); } else { return fn.asText(); } } ``` ### Changes Add check the jsonNode binary type and convert to binaryValue instead of `asText`.
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.
Fix #7657
Motivation
In
GenericJsonRecord.java
, it deserialize byte to String.Changes
Add check the jsonNode binary type and convert to binaryValue instead of
asText
.