Skip to content

jakartified adaptation of the #5282 #5309

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ protected ConsumesProducesAcceptor(
/**
* Determines whether this {@code ConsumesProducesAcceptor} router can process the {@code request}.
*
* @param requestContext The request to be tested.
* @param contentType The media type of the {@code request} to be tested (can be NULL).
* @return True if the {@code request} can be processed by this router, false otherwise.
*/
abstract boolean isConsumable(ContainerRequest requestContext);
abstract boolean isConsumable(MediaType contentType);

@Override
public String toString() {
Expand Down Expand Up @@ -400,8 +400,8 @@ private List<Router> getMethodRouter(final RequestProcessingContext context) {
final List<ConsumesProducesAcceptor> satisfyingAcceptors = new LinkedList<>();
final Set<ResourceMethod> differentInvokableMethods = Collections.newSetFromMap(new IdentityHashMap<>());
final MediaType requestContentType = request.getMediaType();
for (ConsumesProducesAcceptor cpi : acceptors) {
if (cpi.isConsumable(request)) {
for (final ConsumesProducesAcceptor cpi : acceptors) {
if (cpi.isConsumable(requestContentType)) {
satisfyingAcceptors.add(cpi);
differentInvokableMethods.add(cpi.methodRouting.method);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -65,11 +65,11 @@ private ConsumesProducesAcceptor(
/**
* Determines whether this {@code ConsumesProducesAcceptor} router can process the {@code request}.
*
* @param requestContext The request to be tested.
* @param contentType The media type of the {@code request} to be tested (can be NULL).
* @return True if the {@code request} can be processed by this router, false otherwise.
*/
boolean isConsumable(ContainerRequest requestContext) {
MediaType contentType = requestContext.getMediaType();
@Override
boolean isConsumable(MediaType contentType) {
if (contentType == null && methodRouting.method.getType() != ResourceMethod.JaxrsType.SUB_RESOURCE_LOCATOR
&& methodRouting.method.getInvocable().requiresEntity()) {
contentType = MediaType.APPLICATION_OCTET_STREAM_TYPE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -68,11 +68,11 @@ private ConsumesProducesAcceptor(
/**
* Determines whether this {@code ConsumesProducesAcceptor} router can process the {@code request}.
*
* @param requestContext The request to be tested.
* @param contentType The media type of the {@code request} to be tested (can be NULL).
* @return True if the {@code request} can be processed by this router, false otherwise.
*/
boolean isConsumable(ContainerRequest requestContext) {
MediaType contentType = requestContext.getMediaType();
@Override
boolean isConsumable(MediaType contentType) {
return contentType == null || consumes.getMediaType().isCompatible(contentType);
}
}
Expand Down