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

Deprecate Base64Utils #28434

Closed
wants to merge 6 commits into from
Closed

Deprecate Base64Utils #28434

wants to merge 6 commits into from

Conversation

j3graham
Copy link
Contributor

@j3graham j3graham commented May 9, 2022

The java.util.Base64 Encoder and Decoder classes have methods that accept strings as well as return strings. These can be used directly instead of converting between bytes and strings in the Spring classes.

This might also create a tiny performance improvement due to the java.util use of a deprecated, but useful String constructor, as well as its use of ISO_8859_1 encoding when converting strings to bytes. Given the allowable character range, ISO_8859_1 will result in the same conversions.

It appears that Base64Utils is only used within Spring Framework in GsonBuilderUtils, so a possibility would be to have that class use java.util.Base64 directly, and deprecateBase64Utils.

A final observation - Base64Utils has explicit checks for empty strings and byte array parameters. The outputs are the same without , just potentially doing a bit more work before reaching the same answer. if these checks were intended as a safety-check as opposed to a performance optimization, these checks could also be removed.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 9, 2022
@snicoll snicoll added this to the Triage Queue milestone Sep 5, 2022
@bclozel bclozel self-assigned this Jan 17, 2023
@bclozel bclozel changed the title Simplify Base64Utils Deprecate Base64Utils Jan 17, 2023
@bclozel bclozel added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 17, 2023
@bclozel bclozel modified the milestones: Triage Queue, 6.0.5 Jan 17, 2023
@bclozel
Copy link
Member

bclozel commented Jan 17, 2023

I'm repurposing this issue to completely deprecate Base64Utils for future removal. It was originally designed to support both commons-codecs as well as the Java 8 API, if present. Since then, it's passing calls to Java's Base64 without additional checks or behavior.

We should remove all usage of this API within Spring Framework and mark it for future removal.

bclozel pushed a commit that referenced this pull request Jan 17, 2023
This commit simplifies the `Base64Utils` implementation by relying more
on the `Base64` methods that perform similar work.

See gh-28434
@bclozel bclozel closed this in 5448e81 Jan 17, 2023
mdeinum pushed a commit to mdeinum/spring-framework that referenced this pull request Jun 29, 2023
This commit simplifies the `Base64Utils` implementation by relying more
on the `Base64` methods that perform similar work.

See spring-projectsgh-28434
mdeinum pushed a commit to mdeinum/spring-framework that referenced this pull request Jun 29, 2023
Originally, `Base64Utils` was providing base64 encoding and decoding
utilities, bridging to commons-codecs or Java 8, if available. Since
then, only the Java 8 variant remains and Spring Framework 6 requires
now Java 17. This utility class doesn't provide additional checks or
syntactic sugar over what's in Java already.

As a result, this commit deprecates this class in favor of `Base64` and
schedules the removal of this class completely.

Closes spring-projectsgh-28434
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants