@Test public void bracketAsync() throws SQLException { ResultSet resultSet = mock(ResultSet.class); when(resultSet.getString("id")).thenReturn("value"); IO<Try<String>> bracket = IO.bracket(open(resultSet), IO.lift(tryGetString("id"))); Future<Try<String>> future = bracket.foldMap(FutureInstances.async()).fix(toFuture()); assertEquals(Try.success("value"), future.await().get()); verify(resultSet, timeout(1000)).close(); }
@Override public void close() { release.accept(resource); }
IOResource implements AutoCloseable { @Override public void close() { release.accept(resource); } }
IOResource implements AutoCloseable { @Override public void close() { release.accept(resource); } IOResource(T resource, Consumer1<? super T> release); }
IOResource implements AutoCloseable { @Override public void close() { release.accept(resource); } IOResource(T resource, Consumer1<? super T> release); IO<R> apply(Function1<? super T, ? extends IO<? extends R>> use); @Override void close(); }
IOResource implements AutoCloseable { @Override public void close() { release.accept(resource); } IOResource(T resource, Consumer1<? super T> release); IO<R> apply(Function1<? super T, ? extends IO<? extends R>> use); @Override void close();  }