migrate to try-with-resources

This commit is contained in:
Adrian Siekierka
2019-04-22 00:39:09 +02:00
parent 253c2ed15e
commit 221fcf2f51
8 changed files with 40 additions and 58 deletions

View File

@@ -83,8 +83,7 @@ public final class MixinRefmapHelper {
ZipUtil.iterate(output, (stream, entry) -> {
if (!entry.isDirectory() && entry.getName().endsWith(".json") && !entry.getName().contains("/") && !entry.getName().contains("\\")) {
// JSON file in root directory
InputStreamReader inputStreamReader = new InputStreamReader(stream);
try {
try (InputStreamReader inputStreamReader = new InputStreamReader(stream)) {
JsonObject json = GSON.fromJson(inputStreamReader, JsonObject.class);
if (json != null) {
@@ -100,9 +99,6 @@ public final class MixinRefmapHelper {
}
} catch (Exception e) {
// ...
} finally {
inputStreamReader.close();
stream.close();
}
}
});
@@ -116,17 +112,13 @@ public final class MixinRefmapHelper {
ZipUtil.iterate(output, (stream, entry) -> {
if (!entry.isDirectory() && entry.getName().endsWith(".json") && !entry.getName().contains("/") && !entry.getName().contains("\\")) {
// JSON file in root directory
InputStreamReader inputStreamReader = new InputStreamReader(stream);
try {
try (InputStreamReader inputStreamReader = new InputStreamReader(stream)) {
JsonObject json = GSON.fromJson(inputStreamReader, JsonObject.class);
if (json != null && json.has("refmap")) {
mixinRefmapFilenames.add(json.get("refmap").getAsString());
}
} catch (Exception e) {
// ...
} finally {
inputStreamReader.close();
stream.close();
}
}
});