@Override
        public final void close() {
            final boolean wasReleasedBefore = isReleased.getAndSet(true);
            if (wasReleasedBefore) {
                final String message = "Reference is already released and can only be released once."
                        + " State={ " + getReferences().currentState() + " }";
                throw new IllegalStateException(message);
            }
            onClose();
        }
Ensures that a ResourceReference can only be closed exactly once.

@author baldersheim
jdisc_core/src/main/java/com/yahoo/jdisc/refcount/CloseableOnce.java