Skip to content

Commit

Permalink
#1961 close JsonReader correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
mximp committed Apr 3, 2023
1 parent e940f2c commit 1caef19
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,12 @@ public Iterator<Dependency> iterator() {
final Collection<Dependency> all = new ArrayList<>(0);
if (Files.exists(this.file)) {
Logger.debug(this, String.format("Dependencies file: %s", this.file));
final JsonReader reader = Json.createReader(Files.newBufferedReader(this.file));
final JsonArray artifacts = reader.readObject()
.getJsonArray("artifacts");
final JsonArray artifacts;
try (JsonReader reader =
Json.createReader(Files.newBufferedReader(this.file))
) {
artifacts = reader.readObject().getJsonArray("artifacts");
}
for (final JsonValue artifact : artifacts) {
final JsonObject obj = artifact.asJsonObject();
final String group = obj.getString("groupId");
Expand Down

0 comments on commit 1caef19

Please sign in to comment.