Skip to content

Commit

Permalink
Fix #5939 unwrap ServletException
Browse files Browse the repository at this point in the history
reverted default to false

Signed-off-by: Greg Wilkins <gregw@webtide.com>
  • Loading branch information
gregw committed Feb 8, 2021
1 parent 5f784b6 commit 34de084
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,19 @@ private enum PageLookupTechnique
private final Map<String, String> _errorPages = new HashMap<>(); // code or exception to URL
private final List<ErrorCodeRange> _errorPageList = new ArrayList<>(); // list of ErrorCode by range
protected ServletContext _servletContext;
private boolean _unwrapServletException = true;
private boolean _unwrapServletException = false;

/**
* @return True if ServletException is unwrapped for {@link Dispatcher#ERROR_EXCEPTION}
*/
public boolean isUnwrapServletException()
{
return _unwrapServletException;
}

/**
* @param unwrapServletException True if ServletException should be unwrapped for {@link Dispatcher#ERROR_EXCEPTION}
*/
public void setUnwrapServletException(boolean unwrapServletException)
{
_unwrapServletException = unwrapServletException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,20 @@ public void testErrorCode() throws Exception
@Test
public void testErrorException() throws Exception
{
_errorPageErrorHandler.setUnwrapServletException(false);
try (StacklessLogging stackless = new StacklessLogging(HttpChannel.class))
{
String response = _connector.getResponse("GET /fail/exception HTTP/1.0\r\n\r\n");
assertThat(response, Matchers.containsString("HTTP/1.1 500 Server Error"));
assertThat(response, Matchers.containsString("ERROR_PAGE: /TestException"));
assertThat(response, Matchers.containsString("ERROR_CODE: 500"));
assertThat(response, Matchers.containsString("ERROR_EXCEPTION: javax.servlet.ServletException: java.lang.IllegalStateException: Test Exception"));
assertThat(response, Matchers.containsString("ERROR_EXCEPTION_TYPE: class javax.servlet.ServletException"));
assertThat(response, Matchers.containsString("ERROR_SERVLET: org.eclipse.jetty.servlet.ErrorPageTest$FailServlet-"));
assertThat(response, Matchers.containsString("ERROR_REQUEST_URI: /fail/exception"));
}

_errorPageErrorHandler.setUnwrapServletException(true);
try (StacklessLogging stackless = new StacklessLogging(HttpChannel.class))
{
String response = _connector.getResponse("GET /fail/exception HTTP/1.0\r\n\r\n");
Expand Down

0 comments on commit 34de084

Please sign in to comment.