Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.

support custom content-type#113

Merged
zyxxoo merged 4 commits intoapache:masterfrom
z7658329:feat/fix_contenttype
Nov 1, 2022
Merged

support custom content-type#113
zyxxoo merged 4 commits intoapache:masterfrom
z7658329:feat/fix_contenttype

Conversation

@z7658329
Copy link
Copy Markdown
Member

No description provided.

@imbajin imbajin requested a review from javeme October 31, 2022 07:54
@codecov
Copy link
Copy Markdown

codecov bot commented Oct 31, 2022

Codecov Report

Merging #113 (0bf023d) into master (dc3e9e2) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##             master     #113   +/-   ##
=========================================
  Coverage     93.15%   93.15%           
  Complexity       65       65           
=========================================
  Files             9        9           
  Lines           263      263           
  Branches         22       22           
=========================================
  Hits            245      245           
  Misses            8        8           
  Partials         10       10           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

zyxxoo
zyxxoo previously approved these changes Oct 31, 2022
if (MapUtils.isNotEmpty(headers) && headers.get("Content-Type") != null) {
Object contentTypeObj = headers.get("Content-Type");
if (contentTypeObj instanceof List) {
customContentType = ((List) contentTypeObj).get(0).toString();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use List<?> to avoid warning

Copy link
Copy Markdown
Member

@imbajin imbajin Nov 4, 2022

Choose a reason for hiding this comment

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

After checking the code, I found the MultivaluedMap will always return List<V>, so we should change the code logic early

image

@zyxxoo zyxxoo merged commit 16602cc into apache:master Nov 1, 2022
* @param headers
* @return
*/
public static MediaType parseCustomContentType(MultivaluedMap<String, Object> headers) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe private static should be better, but it's not a big problem

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

i will fix this case in next PR

if (MapUtils.isNotEmpty(headers) && headers.get("Content-Type") != null) {
Object contentTypeObj = headers.get("Content-Type");
if (contentTypeObj instanceof List) {
customContentType = ((List<?>) contentTypeObj).get(0).toString();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is the contentTypeObj possible to be empty

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it will happens, but i think no one will write code like this:
headers.put("Content-Type", LIsts.newArrayList());

i will fix this case in next PR

public static MediaType parseCustomContentType(MultivaluedMap<String, Object> headers) {
String customContentType = null;
if (MapUtils.isNotEmpty(headers) && headers.get("Content-Type") != null) {
Object contentTypeObj = headers.get("Content-Type");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

seems we don't need Object here, just use List<?>

String customContentType = null;
if (MapUtils.isNotEmpty(headers) && headers.get("Content-Type") != null) {
Object contentTypeObj = headers.get("Content-Type");
if (contentTypeObj instanceof List) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

and here the judge is redundant, change it to xx != null, I address them in PR #115

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants