Skip to content

Thumbnails.of() do not close output file on v0.4.9 #148

@Nick-IV

Description

@Nick-IV

My test-cases was failed after moving on v0.4.9. Rollback on v0.4.8 restore functionality.

Here is simple test which allow to reproduce the issue:

@Test
public void failure() throws IOException {
    File tmpDir = new File(System.getProperty("user.dir") + "\\target\\tmp");
    String sourceDirString = System.getProperty("user.dir") + "\\src\\test\\resources";
    File dscfJpg = new File(sourceDirString,"DSCF0001.JPG");

    // @Before
    if(!tmpDir.exists()) {
        tmpDir.mkdirs();
    }
    // @Before

    Thumbnails.of( new FileInputStream(dscfJpg) )
            .size(500, 500)
            .toFile( new File(tmpDir.getAbsolutePath(), "toJpeg.jpg") );

    // @After
    if(tmpDir.exists()) {
        FileUtils.deleteDirectory(tmpDir);
    }
    // @After
}

In result:
java.io.IOException: Unable to delete file: D:{cut}\target\tmp\toJpeg.jpg
File stay locked while java process works.
If I will call several Thumbnails.of() in a row just last one will be locked.

Windows 10 1607 LTSC
OpenJDK 11.0.1

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions