Closed CLovinr closed 4 years ago
The reference of the file should be released when Thumbnails.of(tempImgFile) used.
Thumbnails.of(tempImgFile)
After Thumbnails.of(tempImgFile)...toFile(targetFile),the tempImgFile could not be deleted.
Thumbnails.of(tempImgFile)...toFile(targetFile)
This is a simple test to reproduce the behavior:
@Test public void test1ThumbnailsFileBug() throws IOException { File temp1ImgFile = new File("E:/MyFiles/Win10Moved/Pictures/Saved Pictures/temp1.jpg"); File target1ImgFile = new File("E:/MyFiles/Win10Moved/Pictures/Saved Pictures/target1.jpg"); Thumbnails.Builder fileBuilder = Thumbnails.of(temp1ImgFile); fileBuilder.width(256); fileBuilder.height(256); fileBuilder.outputQuality(0.8f); fileBuilder.outputFormat("jpg"); fileBuilder.toFile(target1ImgFile); Assert.assertTrue(temp1ImgFile.delete());//delete fail for '0.4.9' and '0.4.10',sucess for '0.4.8' } @Test public void test2ThumbnailsFileBug() throws IOException { File temp2ImgFile = new File("E:/MyFiles/Win10Moved/Pictures/Saved Pictures/temp2.jpg"); File target2ImgFile = new File("E:/MyFiles/Win10Moved/Pictures/Saved Pictures/target2.jpg"); try (InputStream in = new FileInputStream(temp2ImgFile))//close the input file myself { Thumbnails.Builder fileBuilder = Thumbnails.of(in); fileBuilder.width(256); fileBuilder.height(256); fileBuilder.outputQuality(0.8f); fileBuilder.outputFormat("jpg"); fileBuilder.toFile(target2ImgFile); } Assert.assertTrue(temp2ImgFile.delete());//delete success }
Thanks for the bug report. I found a place that's likely causing the issue!
This should be fixed in 0.4.11. :)
Expected behavior
The reference of the file should be released when
Thumbnails.of(tempImgFile)
used.Actual behavior
After
Thumbnails.of(tempImgFile)...toFile(targetFile)
,the tempImgFile could not be deleted.Steps to reproduce the behavior
This is a simple test to reproduce the behavior:
Environment