Skip to content

Commit

Permalink
TIKA-4220 -- temporary workaround for tar detection regression in com…
Browse files Browse the repository at this point in the history
…mons-compress
  • Loading branch information
tballison committed Mar 25, 2024
1 parent ea5ae24 commit 01d97ea
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,16 @@ public void parse(InputStream stream, ContentHandler handler, Metadata metadata,
}

TemporaryResources tmp = new TemporaryResources();
try {
_parse(stream, handler, metadata, context, tmp);
} finally {
tmp.close();
}
}

private void _parse(InputStream stream, ContentHandler handler, Metadata metadata,
ParseContext context, TemporaryResources tmp)
throws TikaException, IOException, SAXException {
ArchiveInputStream ais = null;
String encoding = null;
try {
Expand Down Expand Up @@ -304,11 +314,9 @@ public void parse(InputStream stream, ContentHandler handler, Metadata metadata,
// Pending a fix for COMPRESS-269 / TIKA-1525, this bit is a little nasty
ais = new SevenZWrapper(sevenz);
} else {
tmp.close();
throw new TikaException("Unknown non-streaming format " + sne.getFormat(), sne);
}
} catch (ArchiveException e) {
tmp.close();
throw new TikaException("Unable to unpack document stream", e);
}

Expand Down Expand Up @@ -340,7 +348,6 @@ public void parse(InputStream stream, ContentHandler handler, Metadata metadata,
}
} finally {
ais.close();
tmp.close();
xhtml.endDocument();
}
}
Expand Down

0 comments on commit 01d97ea

Please sign in to comment.