Class Cleanup.CollectionCloseTask

    • Field Detail

      • coll

        protected final Collection<?> coll
        The collection of which to close its elements which implement AutoCloseable.
    • Constructor Detail

      • CollectionCloseTask

        public CollectionCloseTask​(String descriptor,
                                   Logger logger,
                                   Collection<?> coll)
        Creates a new Cleanup.CollectionCloseTask for the designated Collection, the designated descriptor and the designated logger.
        Parameters:
        descriptor - A string that meaningfully describes this task when used for logging etc. or null.
        logger - The logger for messages and/or problems, e. g. unexpected exceptions.
        coll - The collection of which to AutoCloseable.close() the elements.
      • CollectionCloseTask

        public CollectionCloseTask​(String descriptor,
                                   Logger logger,
                                   Collection<?> coll,
                                   Function<? super AutoCloseable,​AutoCloseable> conversion)
        Creates a new Cleanup.CollectionCloseTask for the designated Collection, the designated conversion applied to the collection elements before closing them, the designated descriptor and the designated logger.
        Parameters:
        descriptor - A string that meaningfully describes this task when used for logging etc. or null.
        logger - The logger for messages and/or problems, e. g. unexpected exceptions.
        coll - The collection of which to AutoCloseable.close() the elements.
        conversion - A function to convert the collection elements before closing. This allows to handler instances that are wrapped by a close ignoring wrapper. This may be null.
    • Method Detail

      • cleanup

        public void cleanup​(boolean explicit)
                     throws Exception
        Description copied from interface: CleanupTask
        Performs the actual clean-up. This method is only called by Cleanup and must NOT be called directly!
        Parameters:
        explicit - Whether the clean-up was triggered explicitly via Cleanup.clean(). Otherwise it was triggered implicitly as a post-mortem action by the object becoming phantom reachable.
        Throws:
        Exception