@Test
public void testCloseWhenFlushThrowingIOException() throws Exception {

  MockOutputStream out = new MockOutputStream();
  SyncableDataOutputStream sdos = new SyncableDataOutputStream(out);
  out.flushThrowIOE = true;
  LambdaTestUtils.intercept(IOException.class, "An IOE from flush", () -> sdos.close());
  MockOutputStream out2 = new MockOutputStream();
  out2.flushThrowIOE = true;
  LambdaTestUtils.intercept(IOException.class, "An IOE from flush", () -> {
    try (SyncableDataOutputStream sdos2 = new SyncableDataOutputStream(out2)) {
    }
  });
}