diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java index 2248a8f7763ac5..3db35defa7d121 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java @@ -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) { diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/ClassRoutingHandler.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/ClassRoutingHandler.java index df1d6de283c35b..1b8fdc9b901d7e 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/ClassRoutingHandler.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/ClassRoutingHandler.java @@ -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); diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/FixedProducesHandler.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/FixedProducesHandler.java index 8029481fc125c9..6e77dbf23e29d4 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/FixedProducesHandler.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/FixedProducesHandler.java @@ -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);