Skip to content

Commit

Permalink
jakartified adaptation of the #5282
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Nesen <[email protected]>
  • Loading branch information
senivam committed Apr 19, 2023
1 parent 91d2fd1 commit 2404a57
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
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

0 comments on commit 2404a57

Please sign in to comment.