Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close locale streams #1832

Merged
merged 2 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ public static Reflections getReflections(String path) {
* @return The byte array of the file
*/
public static byte[] readAllBytes(File file) {
try {
return readAllBytes(new FileInputStream(file));
try (InputStream inputStream = new FileInputStream(file)) {
return readAllBytes(inputStream);
} catch (IOException e) {
throw new RuntimeException("Cannot read " + file);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ private static void loadLocale(String locale) {

// Insert the locale into the mappings
LOCALE_MAPPINGS.put(locale.toLowerCase(), langMap);

try {
localeStream.close();
} catch (IOException e) {
throw new AssertionError(LanguageUtils.getLocaleStringLog("geyser.locale.fail.file", locale, e.getMessage()));
}
} else {
GeyserConnector.getInstance().getLogger().warning(LanguageUtils.getLocaleStringLog("geyser.locale.fail.missing", locale));
}
Expand Down