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! BTW no need to close the PR, you can just add commits or force push
to the existing branch!
----------------------------------------------------------------
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