Skip to content

Commit

Permalink
Fixes #4011 - Add isWriterAcquired to WebApplicationResponse (#4012)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnriem committed Sep 25, 2024
1 parent ece5db3 commit 9d0790e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 9d0790e

Please sign in to comment.