@Test public void close() { int[] counter = { 0 }; ExactlyOnceCloseable c = ExactlyOnceCloseable.wrap(() -> counter[0]++); c.close(); c.close(); assertEquals(1, counter[0]); }
@Override public void close() { try { UPDATER.getAndUpdate(this, c -> () -> { }).close(); } catch (Exception ignore) { Logger.getLogger(ExactlyOnceCloseable.class.getName()).log( Level.FINER, ignore.getMessage(), ignore); } }
ExactlyOnceCloseable implements AutoCloseable { @Override public void close() { try { UPDATER.getAndUpdate(this, c -> () -> { }).close(); } catch (Exception ignore) { Logger.getLogger(ExactlyOnceCloseable.class.getName()).log( Level.FINER, ignore.getMessage(), ignore); } } }
ExactlyOnceCloseable implements AutoCloseable { @Override public void close() { try { UPDATER.getAndUpdate(this, c -> () -> { }).close(); } catch (Exception ignore) { Logger.getLogger(ExactlyOnceCloseable.class.getName()).log( Level.FINER, ignore.getMessage(), ignore); } } ExactlyOnceCloseable(AutoCloseable closeable); }
ExactlyOnceCloseable implements AutoCloseable { @Override public void close() { try { UPDATER.getAndUpdate(this, c -> () -> { }).close(); } catch (Exception ignore) { Logger.getLogger(ExactlyOnceCloseable.class.getName()).log( Level.FINER, ignore.getMessage(), ignore); } } ExactlyOnceCloseable(AutoCloseable closeable); static ExactlyOnceCloseable wrap(AutoCloseable c); @Override void close(); }
ExactlyOnceCloseable implements AutoCloseable { @Override public void close() { try { UPDATER.getAndUpdate(this, c -> () -> { }).close(); } catch (Exception ignore) { Logger.getLogger(ExactlyOnceCloseable.class.getName()).log( Level.FINER, ignore.getMessage(), ignore); } } ExactlyOnceCloseable(AutoCloseable closeable); static ExactlyOnceCloseable wrap(AutoCloseable c); @Override void close();  }