Skip to content

Commit

Permalink
Remove unnecessary content type checks
Browse files Browse the repository at this point in the history
These checks have potentially already
been performed in ClassRoutingHandler

Closes: quarkusio#37637
  • Loading branch information
geoand committed Dec 11, 2023
1 parent 5d4c70a commit bc20239
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,18 @@ public void initPathSegments() {
}
}

private static final String PRODUCES_CHECKED_PROPERTY_KEY = AbstractResteasyReactiveContext.CUSTOM_RR_PROPERTIES_PREFIX
+ "ProducesChecked";

public void setProducesChecked(boolean checked) {
setProperty(PRODUCES_CHECKED_PROPERTY_KEY, checked);
}

public boolean isProducesChecked() {
Object val = getProperty(PRODUCES_CHECKED_PROPERTY_KEY);
return val != null && (boolean) val;
}

@Override
public Object getHeader(String name, boolean single) {
if (httpHeaders == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ public void handle(ResteasyReactiveRequestContext requestContext) throws Excepti
throw new NotAcceptableException(INVALID_ACCEPT_HEADER_MESSAGE);
}
}

requestContext.setProducesChecked(true);
}

requestContext.restart(target.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void handle(ResteasyReactiveRequestContext requestContext) throws Excepti
if (acceptValues.isEmpty()) {
requestContext.setResponseContentType(mediaType);
requestContext.setEntityWriter(writer);
} else {
} else if (!requestContext.isProducesChecked()) {
boolean handled = false;
for (int i = 0; i < acceptValues.size(); i++) {
String accept = acceptValues.get(i);
Expand Down

0 comments on commit bc20239

Please sign in to comment.