OpenRefine
OpenRefine copied to clipboard
Fix: close FileInputStream in loadLanguage to prevent file handle leak
Pull Request: Fix language file handle leak
Closes: #7759
Summary
- Fixes a file-handle leak when loading translation files in
LoadLanguageCommand.loadLanguage().
What I changed
- File:
main/src/com/google/refine/commands/lang/LoadLanguageCommand.java - Replaced manual
FileInputStreamhandling with a try-with-resources block so theFileInputStreamandReaderare always closed on success or error.
Why
- Previously the
FileInputStreamcould remain open when parsing failed or on early returns, which can exhaust file descriptors under repeated requests.
How to reproduce (before)
- Start OpenRefine.
- Trigger the language-load path for a module (e.g., load translation-XX.json).
- Force a parse error or repeat the request many times and observe open file handles (e.g., with
lsof -p <pid>).
How this fixes it
- Using try-with-resources ensures the
FileInputStreamand wrappedReaderare closed automatically even on exceptions.
Testing performed
- Compiled the edited file locally with the project classpath;
javacproducedLoadLanguageCommand.class. - Verified a commit was created with Signed-off-by and pushed the branch
fix/close-language-file-handleto origin.
Notes for reviewer
- Run a full project build
mvn -DskipTests -pl main -am packageto validate. - Optionally run OpenRefine and exercise the language loading endpoint; observe file descriptor counts before/after.
@tfmorris i fixed all the bugs . please verify it