Skip to content

Commit

Permalink
Reduce allocations caused by producible media types
Browse files Browse the repository at this point in the history
Closes gh-29412
  • Loading branch information
dreis2211 authored and sdeleuze committed Nov 2, 2022
1 parent e1df056 commit 58bb6e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Expand Up @@ -141,9 +141,12 @@ protected void handleMatch(RequestMappingInfo info, HandlerMethod handlerMethod,
exchange.getAttributes().put(URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriVariables);
exchange.getAttributes().put(MATRIX_VARIABLES_ATTRIBUTE, matrixVariables);

if (!info.getProducesCondition().getProducibleMediaTypes().isEmpty()) {
Set<MediaType> mediaTypes = info.getProducesCondition().getProducibleMediaTypes();
exchange.getAttributes().put(PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, mediaTypes);
ProducesRequestCondition producesCondition = info.getProducesCondition();
if (!producesCondition.isEmpty()) {
Set<MediaType> mediaTypes = producesCondition.getProducibleMediaTypes();
if (!mediaTypes.isEmpty()) {
exchange.getAttributes().put(PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, mediaTypes);
}
}
}

Expand Down
Expand Up @@ -147,9 +147,12 @@ protected void handleMatch(RequestMappingInfo info, String lookupPath, HttpServl
extractMatchDetails((PatternsRequestCondition) condition, lookupPath, request);
}

if (!info.getProducesCondition().getProducibleMediaTypes().isEmpty()) {
Set<MediaType> mediaTypes = info.getProducesCondition().getProducibleMediaTypes();
request.setAttribute(PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, mediaTypes);
ProducesRequestCondition producesCondition = info.getProducesCondition();
if (!producesCondition.isEmpty()) {
Set<MediaType> mediaTypes = producesCondition.getProducibleMediaTypes();
if (!mediaTypes.isEmpty()) {
request.setAttribute(PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, mediaTypes);
}
}
}

Expand Down

0 comments on commit 58bb6e7

Please sign in to comment.