You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2020/10/09 21:08:29 UTC
[tika] branch main updated: TIKA-3208 -- close the stream in
DetectorResource
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git
The following commit(s) were added to refs/heads/main by this push:
new 172d403 TIKA-3208 -- close the stream in DetectorResource
172d403 is described below
commit 172d40322f5662e428850ad7a8fb4113e453a51c
Author: tallison <ta...@apache.org>
AuthorDate: Fri Oct 9 17:05:33 2020 -0400
TIKA-3208 -- close the stream in DetectorResource
---
.../java/org/apache/tika/server/resource/DetectorResource.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tika-server/src/main/java/org/apache/tika/server/resource/DetectorResource.java b/tika-server/src/main/java/org/apache/tika/server/resource/DetectorResource.java
index bf3d51f..6d3ce89 100644
--- a/tika-server/src/main/java/org/apache/tika/server/resource/DetectorResource.java
+++ b/tika-server/src/main/java/org/apache/tika/server/resource/DetectorResource.java
@@ -50,13 +50,13 @@ public class DetectorResource {
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: {} ({})",