kwin commented on a change in pull request #1: MIME Type detection leaks 
temporary files when given a ZIP file
URL: 
https://github.com/apache/sling-org-apache-sling-commons-contentdetection/pull/1#discussion_r384431929
 
 

 ##########
 File path: 
src/main/java/org/apache/sling/commons/contentdetection/internal/ContentAwareMimeTypeServiceImpl.java
 ##########
 @@ -52,10 +53,14 @@ public String getMimeType(String filename, InputStream 
content) throws IOExcepti
         if(!content.markSupported()) {
             throw new IllegalArgumentException("Supplied InputStream does not 
support mark/reset");
         }
-        TikaInputStream stream = TikaInputStream.get(content);
-        Metadata metadata = new Metadata();
-        metadata.set(Metadata.RESOURCE_NAME_KEY, filename);
-        MediaType mediaType = detector.detect(stream, metadata);
+        MediaType mediaType;
+        TemporaryResources tmp = new TemporaryResources();
 
 Review comment:
   Please use try with resources and don't forget to close tmp: 
https://tika.apache.org/1.8/api/org/apache/tika/io/TikaInputStream.html#get(java.io.InputStream,%20org.apache.tika.io.TemporaryResources)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to