spring-webflow icon indicating copy to clipboard operation
spring-webflow copied to clipboard

infinite loop possible in FlowExecutionImpl.handleException when application code throws exceptions [SWF-428]

Open spring-operator opened this issue 17 years ago • 8 comments

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:

  1. try State handlers, catch the exception if it occurs.
  2. 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:

  1. State level - typically for state-specific application exceptions

  2. Flow level- typically for flow-wide application exceptions

  3. 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:

6 votes, 7 watchers

spring-operator avatar Nov 21 '07 07:11 spring-operator