All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yahoo.jdisc.handler.ContentInputStream Maven / Gradle / Ivy

There is a newer version: 8.441.21
Show newest version
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.handler;

/**
 * This class extends {@link UnsafeContentInputStream} and adds a finalizer to it that calls {@link #close()}. This
 * has a performance impact, but ensures that an unclosed stream does not prevent shutdown.
 *
 * @author Simon Thoresen Hult
 */
public final class ContentInputStream extends UnsafeContentInputStream {

    /**
     * Constructs a new ContentInputStream that reads from the given {@link ReadableContentChannel}.
     *
     * @param content The content to read the stream from.
     */
    public ContentInputStream(ReadableContentChannel content) {
        super(content);
    }

    @Override
    @SuppressWarnings("deprecation")  // finalize() is deprecated from Java 9
    public void finalize() throws Throwable {
        try {
            close();
        } finally {
            super.finalize();
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy