Skip to content

Commit

Permalink
Close locale streams (GeyserMC#1832)
Browse files Browse the repository at this point in the history
* Close locale streams

* Fix formatting
  • Loading branch information
Extollite authored Jan 12, 2021
1 parent af405f3 commit dd0b4ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
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

0 comments on commit dd0b4ba

Please sign in to comment.