diff --git a/core/api/src/main/java/cloud/piranha/core/api/WebApplicationResponse.java b/core/api/src/main/java/cloud/piranha/core/api/WebApplicationResponse.java index 8bd312b253..858a4b58ea 100644 --- a/core/api/src/main/java/cloud/piranha/core/api/WebApplicationResponse.java +++ b/core/api/src/main/java/cloud/piranha/core/api/WebApplicationResponse.java @@ -98,6 +98,13 @@ public interface WebApplicationResponse extends HttpServletResponse { */ boolean isBufferResetting(); + /** + * Is the writer acquired. + * + * @return true if it is, false otherwise. + */ + boolean isWriterAcquired(); + /** * Set the committed flag. * diff --git a/core/impl/src/main/java/cloud/piranha/core/impl/DefaultServletRequestDispatcher.java b/core/impl/src/main/java/cloud/piranha/core/impl/DefaultServletRequestDispatcher.java index 12073a743e..c8dcb23ddd 100644 --- a/core/impl/src/main/java/cloud/piranha/core/impl/DefaultServletRequestDispatcher.java +++ b/core/impl/src/main/java/cloud/piranha/core/impl/DefaultServletRequestDispatcher.java @@ -203,7 +203,7 @@ public void request(DefaultWebApplicationRequest webappRequest, DefaultWebApplic rethrow(e); } } else if (exception != null) { - if (webappResponse.gotWriter) { + if (webappResponse.isWriterAcquired()) { exception.printStackTrace(webappResponse.getWriter()); } else { exception.printStackTrace(new PrintStream(webappResponse.getOutputStream())); diff --git a/core/impl/src/main/java/cloud/piranha/core/impl/DefaultWebApplicationResponse.java b/core/impl/src/main/java/cloud/piranha/core/impl/DefaultWebApplicationResponse.java index cc0cf3a349..207db1e587 100644 --- a/core/impl/src/main/java/cloud/piranha/core/impl/DefaultWebApplicationResponse.java +++ b/core/impl/src/main/java/cloud/piranha/core/impl/DefaultWebApplicationResponse.java @@ -451,6 +451,11 @@ private boolean isInclude() { return request != null && request.getDispatcherType() == DispatcherType.INCLUDE; } + @Override + public boolean isWriterAcquired() { + return gotWriter; + } + @Override public void reset() { verifyNotCommitted("reset");