You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tika.apache.org by "Peter Lee (Jira)" <ji...@apache.org> on 2020/09/14 13:42:00 UTC
[jira] [Created] (TIKA-3197) TikaInputStream may not be closed
Peter Lee created TIKA-3197:
-------------------------------
Summary: TikaInputStream may not be closed
Key: TIKA-3197
URL: https://issues.apache.org/jira/browse/TIKA-3197
Project: Tika
Issue Type: Bug
Components: parser
Reporter: Peter Lee
This is TikaInputStream's close method :
{code:java}
public void close() throws IOException {
path = null;
mark = -1;
tmp.addResource(in);
tmp.close();
}
{code}
It will clean the TemporaryResources and close the InputStream which we orginal get in parameter.
This is TikaInputStream's get method :
{code:java}
public static TikaInputStream get(InputStream stream, TemporaryResources tmp) {
if (stream == null) {
throw new NullPointerException("The Stream must not be null");
}
if (stream instanceof TikaInputStream) {
return (TikaInputStream) stream;
} else {
// Make sure that the stream is buffered and that it
// (properly) supports the mark feature
if (!(stream.markSupported())) {
stream = new BufferedInputStream(stream);
}
return new TikaInputStream(stream, tmp, -1);
}
}{code}
If stream is not instance of TikaInputStream, *it will create and return a new instance of TikaInputStream.*
And as you can see , *we will not close this new instance in close method in this case*. We will only close the InputStream which we orginal get in parameter.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)