Class RunnableErrorForwarder
java.lang.Object
org.eclipse.aether.util.concurrency.RunnableErrorForwarder
A utility class to forward any uncaught
Error
or RuntimeException
from a Runnable
executed in
a worker thread back to the parent thread. The simplified usage pattern looks like this:
RunnableErrorForwarder errorForwarder = new RunnableErrorForwarder(); for ( Runnable task : tasks ) { executor.execute( errorForwarder.wrap( task ) ); } errorForwarder.await();
-
Constructor Summary
ConstructorDescriptionCreates a new error forwarder for worker threads spawned by the current thread. -
Method Summary
Modifier and TypeMethodDescriptionvoid
await()
Causes the current thread to wait until all previouslywrapped
runnables have terminated and potentially re-throws an uncaughtRuntimeException
orError
from any of the runnables.Wraps the specified runnable into an equivalent runnable that will allow forwarding of uncaught errors.
-
Constructor Details
-
RunnableErrorForwarder
public RunnableErrorForwarder()Creates a new error forwarder for worker threads spawned by the current thread.
-
-
Method Details
-
wrap
Wraps the specified runnable into an equivalent runnable that will allow forwarding of uncaught errors.- Parameters:
runnable
- The runnable from which to forward errors, must not benull
.- Returns:
- The error-forwarding runnable to eventually execute, never
null
.
-
await
Causes the current thread to wait until all previouslywrapped
runnables have terminated and potentially re-throws an uncaughtRuntimeException
orError
from any of the runnables. In case multiple runnables encountered uncaught errors, one error is arbitrarily selected. Note: This method must be called from the same thread that created this error forwarder instance.
-