Skip to content

GifImage#loadFrom(File) has a resource leak #2

@AlexanderSchuetz97

Description

@AlexanderSchuetz97

public int loadFrom(File file) throws FileNotFoundException {
if (!file.exists()) throw new FileNotFoundException("File does not exist");
return loadFrom(new FileInputStream(file));
}

The FileInputStream is leaked
Change this to:

public int loadFrom(File file) throws FileNotFoundException {
if (!file.exists()) throw new FileNotFoundException("File does not exist");
try(FileInputStream fais = new FileInputStream(file)) {
return this.loadFrom(fais);
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions