Skip to content
Open
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 @@ -131,10 +131,9 @@ public DependencyGraphParser() {
* Parse the given graph definition.
*/
public DependencyNode parseLiteral(String dependencyGraph) throws IOException {
BufferedReader reader = new BufferedReader(new StringReader(dependencyGraph));
DependencyNode node = parse(reader);
reader.close();
return node;
try (BufferedReader reader = new BufferedReader(new StringReader(dependencyGraph))) {
return parse(reader);
}
}

/**
Expand Down Expand Up @@ -173,19 +172,9 @@ public List<DependencyNode> parseMultiResource(String resource) throws IOExcepti
* Parse the graph definition read from the given URL.
*/
public DependencyNode parse(URL resource) throws IOException {
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(resource.openStream(), StandardCharsets.UTF_8));
try (BufferedReader reader =
new BufferedReader(new InputStreamReader(resource.openStream(), StandardCharsets.UTF_8))) {
return parse(reader);
} finally {
try {
if (reader != null) {
reader.close();
reader = null;
}
} catch (final IOException e) {
// Suppressed due to an exception already thrown in the try block.
}
}
}

Expand Down