[
https://issues.apache.org/jira/browse/TIKA-2384?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16034673#comment-16034673
]
Tim Allison commented on TIKA-2384:
-----------------------------------
>From [~lfcnassif]:
bq. I think resources should be closed where they are opened, like
parser.parse() API contract, no?
I agree. However, we're wrapping the InputStream in a TikaInputStream within
{{TikaResourse.parse()}}.
We want to make absolutely sure to close TikaInputStream in case it has created
temp files, etc.
{noformat}
public static void parse(Parser parser, Logger logger, String path,
InputStream inputStream,
ContentHandler handler, Metadata metadata,
ParseContext parseContext) throws TikaServerParseException {
try (TikaInputStream tikaInputStream =
TikaInputStream.get(inputStream)) {
parser.parse(tikaInputStream, handler, metadata, parseContext);
} catch (SAXException e) {
throw new TikaServerParseException(e);
} catch (EncryptedDocumentException e) {
logger.warn("{}: Encrypted document", path, e);
throw new TikaServerParseException(e);
} catch (Exception e) {
logger.warn("{}: Text extraction failed", path, e);
throw new TikaServerParseException(e);
}
}
{noformat}
> Double close of InputStream in accept text/plain in tika-server
> ---------------------------------------------------------------
>
> Key: TIKA-2384
> URL: https://issues.apache.org/jira/browse/TIKA-2384
> Project: Tika
> Issue Type: Bug
> Components: server
> Affects Versions: 1.15
> Reporter: Tim Allison
> Priority: Blocker
>
> As reported by Haris Osmanagic on the user list, TikaResource closes the
> InputStream twice on requests for text/plain.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)