Class ExceptionSuppressor

  • All Implemented Interfaces:
    FacesListener, SystemEventListener, FacesWrapper<ExceptionHandler>, EventListener
    Direct Known Subclasses:
    ViewExpiredExceptionHandler

    public class ExceptionSuppressor
    extends ExceptionHandlerWrapper

    The ExceptionSuppressor will suppress all exceptions which are an instance of the types as listed in context parameter "org.omnifaces.EXCEPTION_TYPES_TO_SUPPRESS" and refresh the current page by redirecting to the current URL with query string. The context parameter value must be a commaseparated string of fully qualified names of exception types. Note that this also covers subclasses of specified exception types.

     <context-param>
         <param-name>org.omnifaces.EXCEPTION_TYPES_TO_SUPPRESS</param-name>
         <param-value>java.nio.channels.ClosedByInterruptException,java.nio.channels.IllegalSelectorException</param-value>
     </context-param>
     

    This is useful for exceptions which are technically unavoidable such as those which boil down to that the network connection is abruptly closed by the client by e.g. navigating away while the page is loading, or closing the browser window/tab while the page is loading, or having the physical network connection cut down, or the physical machine crashed, etcetera. All which are beyond control of the server and therefore not really interesting to have logged into server logs.

    Installation

    This handler must be registered by a factory as follows in faces-config.xml in order to get it to run:

     <factory>
         <exception-handler-factory>org.omnifaces.exceptionhandler.ExceptionSuppressorFactory</exception-handler-factory>
     </factory>
     

    In case there are multiple exception handlers, best is to register this handler as last one in the chain. For example, when combined with FullAjaxExceptionHandler, this ordering will prevent the FullAjaxExceptionHandler from taking over the handling of the to-be-suppressed exceptions.

     <factory>
         <exception-handler-factory>org.omnifaces.exceptionhandler.FullAjaxExceptionHandlerFactory</exception-handler-factory>
         <exception-handler-factory>org.omnifaces.exceptionhandler.ExceptionSuppressorFactory</exception-handler-factory>
     </factory>
     
    Since:
    3.9
    Author:
    Lenny Primak
    See Also:
    ExceptionSuppressorFactory
    • Field Detail

      • PARAM_NAME_EXCEPTION_TYPES_TO_SUPPRESS

        public static final String PARAM_NAME_EXCEPTION_TYPES_TO_SUPPRESS
        The context parameter name to specify exception types to suppress by ExceptionSuppressor. The context parameter value must be a commaseparated string of fully qualified names of exception types. Note that this also covers subclasses of specified exception types.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ExceptionSuppressor

        public ExceptionSuppressor​(ExceptionHandler wrapped)
        Construct a new exception suppressor around the given wrapped exception handler.
        Parameters:
        wrapped - The wrapped exception handler.
      • ExceptionSuppressor

        @SafeVarargs
        protected ExceptionSuppressor​(ExceptionHandler wrapped,
                                      Class<? extends Throwable>... exceptionTypesToSuppress)
        Construct a new exception suppressor around the given wrapped exception handler and using the given array of exception types to suppress.
        Parameters:
        wrapped - The wrapped exception handler.
        exceptionTypesToSuppress - Array of exception types to suppress.