You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by GitBox <gi...@apache.org> on 2020/02/26 11:37:35 UTC

[GitHub] [sling-org-apache-sling-commons-contentdetection] kwin commented on a change in pull request #2: SLING-9153 - MIME Type detection leaks temporary files when given a ZIP file

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

 ##########
 File path: src/main/java/org/apache/sling/commons/contentdetection/internal/ContentAwareMimeTypeServiceImpl.java
 ##########
 @@ -52,10 +52,16 @@ 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();
+        try {
 
 Review comment:
   Please use https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html instead!

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services