Search code examples
activejdbcjavaliteactiveweb

ControllerRunner's Execution order


this is the activeweb2.0 source code

protected void run(Route route) throws Exception {
    Configuration.injectFilters(); //no worries, will execute once, as filters have a life span of the app
    try {
        try { //nested try , a bit ugly, but we need to ensure filter.after() methods are executed.
            filterBefore(route);
            executeController(route);
        } finally {
            filterAfter(route);
        }
    }
    catch(ActionNotFoundException e){
        throw e;
    }
    catch (RuntimeException e) {
        RequestContext.setControllerResponse(null);//must blow away, as this response is not valid anymore.

        if (exceptionHandled(e, route)) {
            LOGGER.debug("A filter has called render(..) method, proceeding to render it...");
            renderResponse(route);//a filter has created an instance of a controller response, need to render it.
        }else{
            throw e;//if exception was not handled by filter, re-throw
        }
    }
}

if there has DBException happen in executeController, the database connection will be closed.then the rollbackTransaction will not be executed.so there will be some error result in database


Solution

  • You are correct. This issue was reported and fixed in: https://github.com/javalite/activeweb/issues/389.

    Please, upgrade to version 2.2 to get a correct behavior.