@Override public int getPriority() { return delegate.getPriority(); }
@Override public void handleError(HttpServletRequest request, HttpServletResponse response, HandlerContext context) { delegate.handleError(request, response, context); }
@Override public void execute(HttpServletRequest request, HttpServletResponse response) { if (cursor.hasNext()) { boolean hasError = hasError(); Handler handler = new CatchHandler(cursor.next()); if (hasError) { handler.handleError(request, response, this); } else { try { handler.handle(request, response, this); } catch (Exception e) { if (!hasError()) { error(e); } else { // this is major failure which couldn't be handled by catch handler, however we already // processing a fault, there is nothing we can do about that beyond marking occurrence of error. // It is definitely a fatality logger.error("Could not handle request", e); } } } if (!hasError && hasError()) { // we didn't have an error and we have it now, meaning a current handler reported issue. // so here reset cursor and restart execution forcing handleError method execution in reverse order. request.setAttribute(ERROR_ATTRIBUTE, error); cursor = handlers.descendingIterator(); execute(request, response); } } }
@Override public void handle(HttpServletRequest request, HttpServletResponse response, HandlerContext context) { try { delegate.handle(request, response, context); } catch (Exception e) { if (!context.hasError()) { context.error(e); } else { logger.error("Could not handle exception thrown by delegate handler {}", delegate, e); } } }
@Override public void execute(HttpServletRequest request, HttpServletResponse response) { if (cursor.hasNext()) { boolean hasError = hasError(); Handler handler = new CatchHandler(cursor.next()); if (hasError) { handler.handleError(request, response, this); } else { try { handler.handle(request, response, this); } catch (Exception e) { if (!hasError()) { error(e); } else { // this is major failure which couldn't be handled by catch handler, however we already // processing a fault, there is nothing we can do about that beyond marking occurrence of error. // It is definitely a fatality logger.error("Could not handle request", e); } } } if (!hasError && hasError()) { // we didn't have an error and we have it now, meaning a current handler reported issue. // so here reset cursor and restart execution forcing handleError method execution in reverse order. request.setAttribute(ERROR_ATTRIBUTE, error); cursor = handlers.descendingIterator(); execute(request, response); } } }
@Override public void handle(HttpServletRequest request, HttpServletResponse response, HandlerContext context) { try { delegate.handle(request, response, context); } catch (Exception e) { if (!context.hasError()) { context.error(e); } else { logger.error("Could not handle exception thrown by delegate handler {}", delegate, e); } } }
@Override public int getPriority() { return delegate.getPriority(); }
@Override public void handleError(HttpServletRequest request, HttpServletResponse response, HandlerContext context) { delegate.handleError(request, response, context); }