Package com.norconex.crawler.core.util
Class ExceptionSwallower
java.lang.Object
com.norconex.crawler.core.util.ExceptionSwallower
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidclose(AutoCloseable... closeables) Ensures that any exceptions thrown while closing the supplied resource are swallowed and a default message logged.static voidclose(AutoCloseable closeable, String msg) Ensures that any exceptions thrown while closing the supplied resource are swallowed and a custom message logged.static voidcloseQuietly(AutoCloseable... closeables) Ensures that any exceptions thrown while closing the supplied resource are swallowed and no messages are logged about the exception.static voidrunWithInterruptClear(Runnable runnable) Runs the given runnable, clearing the thread's interrupt flag before execution and restoring it after if it was set.static voidrunWithInterruptClearEx(FailableRunnable<Exception> runnable) Runs the given FailableRunnable, clearing the thread's interrupt flag before execution and restoring it after if it was set.static voidswallow(FailableRunnable<Exception> runnable) Ensures that any exceptions thrown while executing are swallowed and a default message logged.static voidswallow(FailableRunnable<Exception> runnable, String msg) Ensures that any exceptions thrown while executing are swallowed and a custom message logged.static voidswallowQuietly(FailableRunnable<Exception> runnable) Ensures that any exceptions thrown while executing are swallowed and no messages are logged about the exception.
-
Method Details
-
swallow
Ensures that any exceptions thrown while executing are swallowed and a default message logged.- Parameters:
runnable- the code to execute
-
swallow
Ensures that any exceptions thrown while executing are swallowed and a custom message logged.- Parameters:
runnable- the code to executemsg- message to log when there is an exception
-
swallowQuietly
Ensures that any exceptions thrown while executing are swallowed and no messages are logged about the exception.- Parameters:
runnable- the code to execute
-
close
Ensures that any exceptions thrown while closing the supplied resource are swallowed and a default message logged.nullarguments are ignored.- Parameters:
closeables- one ore more resources to close
-
close
Ensures that any exceptions thrown while closing the supplied resource are swallowed and a custom message logged.- Parameters:
closeable- resource to closemsg- message to display in case of failure to close
-
closeQuietly
Ensures that any exceptions thrown while closing the supplied resource are swallowed and no messages are logged about the exception.- Parameters:
closeables- one or more resources to close
-
runWithInterruptClear
Runs the given runnable, clearing the thread's interrupt flag before execution and restoring it after if it was set. Useful for shutdown/close logic that must not be interrupted.- Parameters:
runnable- the code to execute
-
runWithInterruptClearEx
Runs the given FailableRunnable, clearing the thread's interrupt flag before execution and restoring it after if it was set. Useful for shutdown/close logic that must not be interrupted. Any thrown exception is propagated.- Parameters:
runnable- the code to execute- Throws:
Exception- if the runnable throws
-