@Test
void testExceptionInClose() {

    final AtomicBoolean fClosed = new AtomicBoolean();
    final AtomicBoolean gClosed = new AtomicBoolean();
    boolean gotException = false;
    final Stream<String> f = Stream.of("F")
            .onClose(() -> fClosed.set(true))
            .onClose(() -> produceException("F"));
    final Stream<String> g = Stream.of("G")
            .onClose(() -> gClosed.set(true))
            .onClose(() -> produceException("G"));
    List<String> result;
    try {
        result = StreamComposition.concatAndAutoClose(a, b, f, g, c).collect(toList());
    } catch (Exception e) {
        gotException = true;
          e.printStackTrace();
    }
    assertTrue(gotException);
    assertAllClosed();
    assertTrue(fClosed.get());
    assertTrue(gClosed.get());
}