blob: d59bb893a2f9bfebddb6e5523b78a0965154710d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.handler;
/**
* <p>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.</p>
*
* @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a>
*/
public final class ContentInputStream extends UnsafeContentInputStream {
/**
* <p>Constructs a new ContentInputStream that reads from the given {@link ReadableContentChannel}.</p>
*
* @param content The content to read the stream from.
*/
public ContentInputStream(ReadableContentChannel content) {
super(content);
}
@Override
public void finalize() throws Throwable {
try {
close();
} finally {
super.finalize();
}
}
}
|