-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-6342: Move workaround for JSON parsing of non-escaped strings #8591
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
Changes from 8 commits
e7c4346
5b48c95
752d831
1e941b9
a14e6cb
ae659d1
1c308a8
438d010
fec67e0
755634f
b9c70ff
bdfa380
802e255
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,16 +35,7 @@ object Json { | |
| */ | ||
| def parseFull(input: String): Option[JsonValue] = | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm probably missing something obvious, but I found the following callers of this function:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The compatibility fix was only required for ACLs, but we added it here to keep the fix small for backporting. The idea was to move to the appropriate place soon after, but it got stuck for a while. Do you have some concerns?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussed this offline with @hachikuji. I had misunderstood his point. It looks like the compatibility code has not been used since 1.1.0:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should just drop this code.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looks like Or shall I just get rid of this code and use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code is fine as it is. We are suggesting that we don't need
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, then I misunderstood it too. :)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @viktorsomogyi I think the argument is that if no-one complained since 1.1 which was released more than 2 years ago, then maybe this issue is very rare.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, that's fair. I've uploaded the changes. |
||
| try Option(mapper.readTree(input)).map(JsonValue(_)) | ||
| catch { | ||
| case _: JsonProcessingException => | ||
| // Before 1.0.1, Json#encode did not escape backslash or any other special characters. SSL principals | ||
| // stored in ACLs may contain backslash as an escape char, making the JSON generated in earlier versions invalid. | ||
| // Escape backslash and retry to handle these strings which may have been persisted in ZK. | ||
| // Note that this does not handle all special characters (e.g. non-escaped double quotes are not supported) | ||
| val escapedInput = input.replaceAll("\\\\", "\\\\\\\\") | ||
| try Option(mapper.readTree(escapedInput)).map(JsonValue(_)) | ||
| catch { case _: JsonProcessingException => None } | ||
| } | ||
| catch { case _: JsonProcessingException => None } | ||
|
|
||
| /** | ||
| * Parse a JSON string into either a generic type T, or a JsonProcessingException in the case of | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.