-
Notifications
You must be signed in to change notification settings - Fork 37.7k
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
Closed
Deprecate Base64Utils #28434
Conversation
This file contains 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
…ng methods from java.util.Base64
spring-projects-issues
added
the
status: waiting-for-triage
An issue we've not yet triaged or decided on
label
May 9, 2022
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
I'm repurposing this issue to completely deprecate 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
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
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.
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 inGsonBuilderUtils
, so a possibility would be to have that class usejava.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.