Interface SafeRunnable

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static org.slf4j.Logger LOGGER  
    • Field Detail

      • LOGGER

        static final org.slf4j.Logger LOGGER
    • Method Detail

      • run

        default void run()
        Specified by:
        run in interface java.lang.Runnable
      • safeRun

        void safeRun()
      • safeRun

        static SafeRunnable safeRun​(java.lang.Runnable runnable)
        Utility method to use SafeRunnable from lambdas.

        Eg:

         
         executor.submit(SafeRunnable.safeRun(() -> {
            // My not-safe code
         });
         
         
      • safeRun

        static SafeRunnable safeRun​(java.lang.Runnable runnable,
                                    java.util.function.Consumer<java.lang.Throwable> exceptionHandler)
        Utility method to use SafeRunnable from lambdas with a custom exception handler.

        Eg:

         
         executor.submit(SafeRunnable.safeRun(() -> {
            // My not-safe code
         }, exception -> {
            // Handle exception
         );
         
         
        Parameters:
        runnable -
        exceptionHandler - handler that will be called when there are any exception
        Returns: