Interface ReferenceCountedObject

    • Method Detail

      • acquireReferences

        Optional<Closeable> acquireReferences()
        This method is expected to increment a reference count and provide a Closeable that decrements the reference count when closed. This is likely just a wrapper around ReferenceCountingCloseableObject.incrementReferenceAndDecrementOnceCloseable(), but may also include any other associated references which should be incremented when this method is called, and decremented/released by the closeable. IMPORTANT NOTE: to fulfill the contract of this method, implementors must return a closeable to indicate that the reference can be acquired, even if there is nothing to close. Implementors should avoid allowing this method or the Closeable it creates to throw exceptions. For callers: if this method returns non-empty, IT MUST BE CLOSED, else reference counts can potentially leak.