diff --git a/tika-core/src/main/java/org/apache/tika/Tika.java b/tika-core/src/main/java/org/apache/tika/Tika.java index 2f17de6451..5d121e6d05 100644 --- a/tika-core/src/main/java/org/apache/tika/Tika.java +++ b/tika-core/src/main/java/org/apache/tika/Tika.java @@ -521,8 +521,8 @@ public String parseToString(InputStream stream, Metadata metadata, int maxLength WriteOutContentHandler handler = new WriteOutContentHandler(maxLength); ParseContext context = new ParseContext(); context.set(Parser.class, parser); - try (InputStream autoCloseStream = stream) { - parser.parse(autoCloseStream, new BodyContentHandler(handler), metadata, context); + try (stream) { + parser.parse(stream, new BodyContentHandler(handler), metadata, context); } catch (SAXException e) { if (!WriteLimitReachedException.isWriteLimitReached(e)) { // This should never happen with BodyContentHandler...