Skip to content

Commit

Permalink
fix: avoid modifying the response after it has been already committed
Browse files Browse the repository at this point in the history
  • Loading branch information
geovanne-duarte-mx committed Oct 15, 2024
1 parent 5f810c9 commit af232a1
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,16 @@ public final void handleException(Exception ex, HttpServletResponse response, Ht
ExceptionFormatter.convertToPathRequestException(ex, response));
}

// Temporarily put back error response writer.
// This fails when a filter fails.
// HttpServletResponse resp = response;
response.reset();
try {
if (!response.isCommitted()) {
response.reset();
}
} catch (IllegalStateException ignored) {
// Ignoring the exception since the response has been already committed
LOGGER.warn("Response already committed, cannot reset or modify.");
return;
}

response.setStatus(status.value());
response.setContentType("application/vnd.mx.mdx.v6+json");

Expand Down

0 comments on commit af232a1

Please sign in to comment.