Miscellaneous
Wrap Exceptions
The ExceptionWrapper class allows you to run arbitrary code in a Callable block catching any Throwable and rethrowing as an exception of your choice. The thrown exception embeds the originating exception as it's cause. For example,
1 2 3 4 5 6 | |
If you'd rather just convert checked exceptions to RuntimeException, just use the 'wrapAsRuntimeException` method. Again, it will embed the originating exception so you won't loose the information.
The example below has the creation of the anonymous Callable class pushed into the method something.
1
| |
Default Thread Factory
Nothing fancy, the DefaultThreadFactory offers the default implementation of java.util.concurrent.ThreadFactory shown below.
1 2 3 4 5 6 | |