spring-webflow
spring-webflow copied to clipboard
infinite loop possible in FlowExecutionImpl.handleException when application code throws exceptions [SWF-428]
ChienHsing Wu opened SWF-428 and commented
FlowExecutionImpl.handleException tries state exception handlers and then flow exception handlers if no state handlers can process that exception. this method expects application side exception handling code not to throw any exceptions, which might not be true sometimes. I think a more robust algorithm for this method is:
- try State handlers, catch the exception if it occurs.
- try the flow handlers, throw the exception to the upper level if one occurs
I think throwing the exception out is better then retry the handlers since Webflow is in a web container and the web container has means to allow applications to handle exceptions too. This forms a hierarchy of exception handlers:
-
State level - typically for state-specific application exceptions
-
Flow level- typically for flow-wide application exceptions
-
Application level - typically for system runtime exceptions
try { try { // the state could be null if the flow was attempting a start operation ViewSelection selectedView = tryStateHandlers(exception, context); if (selectedView != null) { return selectedView; } } catch (FlowExecutionException ex) { logger.warn("tryStateHandlers", ex); } ViewSelection selectedView = tryFlowHandlers(exception, context); if (selectedView != null) { return selectedView; } } catch (FlowExecutionException newException) { logger.error("handleException: failed", newException); } if (logger.isDebugEnabled()) { logger.debug("Rethrowing unhandled flow execution exception"); } throw exception;
Affects: 1.0.5
Attachments:
- TestWebflowBug.zip (3.19 MB)
6 votes, 7 watchers