code: public Closeable decrementOnceCloseable()
    {
      AtomicBoolean decremented = new AtomicBoolean(false);
      return () -> {
        if (decremented.compareAndSet(false, true)) {
          decrement();
        } else {
          log.warn("close() is called more than once on ReferenceCountingSegment.decrementOnceCloseable()");
        }
      };
    }
docs: Returns a {@link Closeable} which action is to call {@link #decrement()} only once. If close() is called on the
  returned Closeable object for the second time, it won't call {@link #decrement()} again.