jakartified adaptation of the #5282 Signed-off-by: Maxim Nesen <maxim.nesen@oracle.com>
diff --git a/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/AbstractMethodSelectingRouter.java b/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/AbstractMethodSelectingRouter.java index 76e96aa..6416ed4 100644 --- a/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/AbstractMethodSelectingRouter.java +++ b/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/AbstractMethodSelectingRouter.java
@@ -201,10 +201,10 @@ /** * 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() { @@ -400,8 +400,8 @@ 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); }
diff --git a/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/OctetStreamMethodSelectingRouter.java b/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/OctetStreamMethodSelectingRouter.java index 47b30a8..c7cc880 100644 --- a/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/OctetStreamMethodSelectingRouter.java +++ b/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/OctetStreamMethodSelectingRouter.java
@@ -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 @@ -65,11 +65,11 @@ /** * 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;
diff --git a/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/WildcardMethodSelectingRouter.java b/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/WildcardMethodSelectingRouter.java index c9f2e49..6559d33 100644 --- a/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/WildcardMethodSelectingRouter.java +++ b/core-server/src/main/java/org/glassfish/jersey/server/internal/routing/WildcardMethodSelectingRouter.java
@@ -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 @@ -68,11 +68,11 @@ /** * 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); } }