Polish "Use try-with-resources to close resources automatically"
- Apply code formatting - Use try-with-resources in many other places that were missed in the pull request Closes gh-8045
This commit is contained in:
@@ -83,12 +83,11 @@ final class ApplicationPluginAction implements PluginApplicationAction {
|
||||
}
|
||||
|
||||
private String loadResource(String name) {
|
||||
InputStreamReader reader = new InputStreamReader(
|
||||
getClass().getResourceAsStream(name));
|
||||
char[] buffer = new char[4096];
|
||||
int read = 0;
|
||||
StringWriter writer = new StringWriter();
|
||||
try {
|
||||
try (InputStreamReader reader = new InputStreamReader(
|
||||
getClass().getResourceAsStream(name));) {
|
||||
char[] buffer = new char[4096];
|
||||
int read = 0;
|
||||
StringWriter writer = new StringWriter();
|
||||
while ((read = reader.read(buffer)) > 0) {
|
||||
writer.write(buffer, 0, read);
|
||||
}
|
||||
@@ -97,14 +96,6 @@ final class ApplicationPluginAction implements PluginApplicationAction {
|
||||
catch (IOException ex) {
|
||||
throw new GradleException("Failed to read '" + name + "'", ex);
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
reader.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
// Continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user