Catch all FileAppenderTest asynchronous errors
Assertions are not exceptions, so they were not passed on to the Junit
thread.
@@ -168,17 +168,17 @@ public class FileAppenderTest {
private void testMultipleLockingAppenderThreads(final boolean lock, final int threadCount, boolean createOnDemand)
throws InterruptedException, Exception {
final ExecutorService threadPool = Executors.newFixedThreadPool(threadCount);
- final AtomicReference<Exception> exceptionRef = new AtomicReference<>();
+ final AtomicReference<Throwable> throwableRef = new AtomicReference<>();
final int logEventCount = 100;
- final Runnable runnable = new FileWriterRunnable(createOnDemand, lock, logEventCount, exceptionRef);
+ final Runnable runnable = new FileWriterRunnable(createOnDemand, lock, logEventCount, throwableRef);
for (int i = 0; i < threadCount; ++i) {
threadPool.execute(runnable);
}
threadPool.shutdown();
assertTrue(
threadPool.awaitTermination(10, TimeUnit.SECONDS), "The thread pool has not shutdown: " + threadPool);
- if (exceptionRef.get() != null) {
- throw exceptionRef.get();
+ if (throwableRef.get() != null) {
+ Throwables.rethrow(throwableRef.get());
}
verifyFile(threadCount * logEventCount);
}
@@ -291,14 +291,14 @@ public class FileAppenderTest {
private final boolean createOnDemand;
private final boolean lock;
private final int logEventCount;
- private final AtomicReference<Exception> exceptionRef;
+ private final AtomicReference<Throwable> throwableRef;
public FileWriterRunnable(
- boolean createOnDemand, final boolean lock, final int logEventCount, final AtomicReference<Exception> exceptionRef) {
+ boolean createOnDemand, final boolean lock, final int logEventCount, final AtomicReference<Throwable> throwableRef) {
this.createOnDemand = createOnDemand;
this.lock = lock;
this.logEventCount = logEventCount;
- this.exceptionRef = exceptionRef;
+ this.throwableRef = throwableRef;
}
@Override
@@ -307,9 +307,8 @@ public class FileAppenderTest {
try {
writer(lock, logEventCount, thread.getName(), createOnDemand, true);
- } catch (final Exception e) {
- exceptionRef.set(e);;
- Throwables.rethrow(e);
+ } catch (final Throwable e) {
+ throwableRef.set(e);
}
}
}
