Skip to content

Commit

Permalink
TIKA-3208 -- close the stream in DetectorResource
Browse files Browse the repository at this point in the history
  • Loading branch information
tballison committed Oct 9, 2020
1 parent d2449f9 commit 172d403
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public DetectorResource(ServerStatus serverStatus) {
public String detect(final InputStream is,
@Context HttpHeaders httpHeaders, @Context final UriInfo info) {
Metadata met = new Metadata();
TikaInputStream tis = TikaInputStream.get(TikaResource.getInputStream(is, met, httpHeaders));
String filename = TikaResource.detectFilename(httpHeaders
.getRequestHeaders());

String filename = TikaResource.detectFilename(httpHeaders.getRequestHeaders());
LOG.info("Detecting media type for Filename: {}", filename);
met.add(TikaCoreProperties.RESOURCE_NAME_KEY, filename);
long taskId = serverStatus.start(ServerStatus.TASK.DETECT, filename);
try {

try (TikaInputStream tis = TikaInputStream.get(TikaResource.getInputStream(is, met, httpHeaders))) {
return TikaResource.getConfig().getDetector().detect(tis, met).toString();
} catch (IOException e) {
LOG.warn("Unable to detect MIME type for file. Reason: {} ({})",
Expand Down

0 comments on commit 172d403

Please sign in to comment.