Skip to content
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

improvement: allowing more granular control of reading behaviour for base64 #646

Merged
merged 7 commits into from
Oct 26, 2020

Conversation

pavan-kalyan
Copy link
Contributor

As Discussed in #500.

Allowing configuration of read behaviour via trio methods (withPadddingForbidden, withPaddingAllowed, withPaddingRequired)
existing usage of usesPadding now changes meaning to writePadding. (maybe this should be renamed?)
also there is a method included withWritePadding(boolean) to allow configuration of whether padding should be written derived from the Base64Variants.

Existing constructors set the following read behaviour. if usesPadding is enabled, then Padding on read is required. if usesPadding is disabled then Padding on Read is forbidden
Testing and validation pending.

@cowtowncoder
Copy link
Member

Excellent! I'll try to have a look over the weekend (there's a healthy backlog of things but I want to make sure this still gets in 2.12).

One other thing is the CLA; if I haven't asked for one, it's here:

https://github.com/FasterXML/jackson/blob/master/contributor-agreement.pdf

and the easiest way usually is to print it, fill & sign, scan/photo, email to info at fasterxml dot com.
Only needs to be done once, and I can merge PRs after we receive and file it.

/**
* Whether padding characters should be required or not while decoding
*/
private final transient PaddingReadBehaviour _paddingReadBehaviour;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove transient here -- not sure why preceding final field has it, possibly copy-paste issue originally (I will remove it from others too)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed transient

@cowtowncoder
Copy link
Member

Looks pretty good; one thing missing (aside from CLA) would be unit tests: just basic demonstration that handling works wrt new settings.

@pavan-kalyan
Copy link
Contributor Author

pavan-kalyan commented Oct 18, 2020

I have made the requested changes (let me know if there are more scenarios/flows that need to be unit tested)
Is there any way to digitally sign the CLA, instead of printing it out?
edit: a few test fixes are pending

@cowtowncoder
Copy link
Member

@pavan-kalyan A few contributors have managed to do it all digitally -- not sure how unfortunately (to share details), but we are fine with digital print as signature, no need to produce physical copy. Just need an image (pdf, png, jpeg) with information and signature of some kind (like ones that are used on online documents, not necessarily based on your handwriting).

@pavan-kalyan
Copy link
Contributor Author

pavan-kalyan commented Oct 23, 2020

I have sent the CLA to the email specified


}

private enum PaddingReadBehaviour {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since exposed by public accessor, needs to be public type (I can change this post-merge).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed and added comments and @since

@cowtowncoder
Copy link
Member

Looks good. Could use some more javadocs in general, but one area where I think description is needed is for Base64Variants, to explain the logic of "if outputs padding, requires on reading; if does not output padding, does not accept", for existing choices.

I hope to get this merged tomorrow, and did receive CLA (thank you!).

@pavan-kalyan
Copy link
Contributor Author

I have added more comments, let me know if there should be more docs.
One doubt I have if these comments are in the right place (https://github.com/FasterXML/jackson-core/pull/646/files#diff-a9b7b3f0fa4f0eb74344f465fc1a1faa6092f4b3a0642809b782c7af68acb923R15-R18). Should these be just above every Variant mentioned?

@cowtowncoder
Copy link
Member

@pavan-kalyan Thanks! I think that comment makes sense both there AND a brief note in each variant (in latter case can just say that "writes padding on output; does not accept padding when reading (may change latter with a call to [LINK to method to change])"?

@pavan-kalyan
Copy link
Contributor Author

pavan-kalyan commented Oct 24, 2020

Changed to writes padding on output; does not accept padding when reading (may change latter with a call to {@link Base64Variant#withWritePadding}

Edit:Just noticed that there is a typo, I'll fix it fixed

Copy link
Member

@cowtowncoder cowtowncoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@cowtowncoder cowtowncoder added this to the 2.12.0-rc2 milestone Oct 26, 2020
@cowtowncoder cowtowncoder merged commit d169161 into FasterXML:2.12 Oct 26, 2020
@cowtowncoder
Copy link
Member

Merged to 2.12, up to master as well. Thank you very much for getting this through!

@pavan-kalyan
Copy link
Contributor Author

Thanks for patiently guiding me through this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants