diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java index dcc5fe72a..bdab59d3b 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java @@ -582,8 +582,10 @@ public class Dispatcher { logConfigurationException(request, e); sendError(request, response, HttpServletResponse.SC_NOT_FOUND, e); } catch (Exception e) { - e.printStackTrace(); if (handleException || devMode) { + if (devMode) { + LOG.debug("Dispatcher serviceAction failed", e); + } sendError(request, response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e); } else { throw new ServletException(e); diff --git a/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java b/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java index 7e25fb11f..88964123a 100644 --- a/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java +++ b/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java @@ -321,6 +321,38 @@ public class DispatcherTest extends StrutsInternalTestCase { assertTrue(du.isMultipartRequest(req)); } + /** + * Verify proper default (true) handleExceptionState for Dispatcher and that + * it properly reflects a manually configured change to false. + * + * @throws Exception + */ + public void testHandleException() throws Exception { + Dispatcher du = initDispatcher(new HashMap()); + assertTrue("Default Dispatcher handleException state not true ?", du.isHandleException()); + + Dispatcher du2 = initDispatcher(new HashMap() {{ + put(StrutsConstants.STRUTS_HANDLE_EXCEPTION, "false"); + }}); + assertFalse("Modified Dispatcher handleException state not false ?", du2.isHandleException()); + } + + /** + * Verify proper default (false) devMode for Dispatcher and that + * it properly reflects a manually configured change to true. + * + * @throws Exception + */ + public void testDevMode() throws Exception { + Dispatcher du = initDispatcher(new HashMap()); + assertFalse("Default Dispatcher devMode state not false ?", du.isDevMode()); + + Dispatcher du2 = initDispatcher(new HashMap() {{ + put(StrutsConstants.STRUTS_DEVMODE, "true"); + }}); + assertTrue("Modified Dispatcher devMode state not true ?", du2.isDevMode()); + } + class InternalConfigurationManager extends ConfigurationManager { public boolean destroyConfiguration = false;