GifImage#loadFrom(File) has a resource leak
- Dominant language
- Java
- Stars
- 6
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
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);
}
}
Contributor guide
No contributing guide indexed for this repository
Research direction
Locate GifImage#loadFrom(File) and inspect how the FileInputStream is created and passed to loadFrom(InputStream). Ensure the stream is closed after the delegated load completes, including when loading fails, and verify that the method still returns the delegated result without changing the missing-file behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100