This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 1b4ed5d618614bc4ec5f065620f7b6f9b5c91774 Author: remm <r...@apache.org> AuthorDate: Mon Mar 4 10:17:39 2024 +0100 Look up response wrappers to suspend BZ 68634 shows the implications and behavior difference between suspend and close for response generation. A flag could be added to make this optional if needed. I will delay backporting this to other branches since this is a behavior change. --- .../apache/catalina/core/ApplicationDispatcher.java | 20 +++++++++++++++----- .../org/apache/catalina/core/LocalStrings.properties | 1 + 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/java/org/apache/catalina/core/ApplicationDispatcher.java b/java/org/apache/catalina/core/ApplicationDispatcher.java index 149ba52ca1..eff85041f6 100644 --- a/java/org/apache/catalina/core/ApplicationDispatcher.java +++ b/java/org/apache/catalina/core/ApplicationDispatcher.java @@ -351,16 +351,26 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher wrapper.getLogger().trace(" Disabling the response for further output"); } + boolean finished = false; if (response instanceof ResponseFacade) { + finished = true; ((ResponseFacade) response).finish(); - } else { + } else if (response instanceof ServletResponseWrapper) { + ServletResponse baseResponse = response; + do { + baseResponse = ((ServletResponseWrapper) baseResponse).getResponse(); + } while (baseResponse instanceof ServletResponseWrapper); + if (baseResponse instanceof ResponseFacade) { + finished = true; + ((ResponseFacade) baseResponse).finish(); + } + } + if (!finished) { // Servlet SRV.6.2.2. The Request/Response may have been wrapped // and may no longer be instance of RequestFacade - if (wrapper.getLogger().isTraceEnabled()) { - wrapper.getLogger() - .trace(" The Response is vehiculed using a wrapper: " + response.getClass().getName()); + if (wrapper.getLogger().isDebugEnabled()) { + wrapper.getLogger().debug(sm.getString("applicationDispatcher.customResponse", response.getClass())); } - // Close anyway try { PrintWriter writer = response.getWriter(); diff --git a/java/org/apache/catalina/core/LocalStrings.properties b/java/org/apache/catalina/core/LocalStrings.properties index 2b00ecfdd8..b6bee67cb6 100644 --- a/java/org/apache/catalina/core/LocalStrings.properties +++ b/java/org/apache/catalina/core/LocalStrings.properties @@ -42,6 +42,7 @@ applicationContext.setSessionTracking.iae.ssl=The session tracking modes request applicationContext.setSessionTracking.ise=The session tracking modes for context [{0}] cannot be set whilst the context is running applicationDispatcher.allocateException=Allocate exception for servlet [{0}] +applicationDispatcher.customResponse=The response class [{0}] could not be unwraped to the Catalina response class and will be closed immediately after the forward applicationDispatcher.deallocateException=Deallocate exception for servlet [{0}] applicationDispatcher.forward.ise=Cannot forward after response has been committed applicationDispatcher.isUnavailable=Servlet [{0}] is currently unavailable --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org