void () { Exception rethrown = null; var text = "should be rethrown"; var in = List.of(1, 2, 3, 4, 5); try { ParallelRunner.<Integer, MyTestException>runInParallelRethrow(in, it -> { throw new MyTestException(text); }); } catch (MyTestException e) { rethrown = e; } assertNotNull(rethrown); assertEquals(text, rethrown.getMessage()); }