New method MediaType.getCharsetParameter() returns charset instance or null#1305
Merged
mkarg merged 1 commit intojakartaee:mainfrom Mar 28, 2025
Merged
Conversation
33d3220 to
94f6fed
Compare
jamezp
approved these changes
Mar 25, 2025
jansupol
approved these changes
Mar 28, 2025
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
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.
Proposal
I like to propose the addition of the new method
MediaType.getCharsetParameter()which either returns aCharsetinstance,null, or throwsUnsupportedCharsetException.Justification
Rather often I came across code like the following lines (quoted from Jersey) in applications, filters and compliant implementations:
https://github.com/eclipse-ee4j/jersey/blob/b128e9c9e649e96488a9c1d367e4cbae89a9d1d4/core-common/src/main/java/org/glassfish/jersey/message/internal/ReaderWriter.java#L127-L130
I do not see any benefit in repeating the obvious again and again, so why not giving away this standard solution for free as part of JAX-RS itself? 😃