@Test public void bracket() 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"))); assertEquals(Try.success("value"), bracket.unsafeRunSync()); verify(resultSet).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();  }