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:
Andy Wilkinson
2017-05-23 17:24:01 +01:00
parent 3e797c326a
commit d5438c299c
78 changed files with 284 additions and 703 deletions

View File

@@ -201,13 +201,9 @@ public class AutoConfigureAnnotationProcessor extends AbstractProcessor {
if (!this.properties.isEmpty()) {
FileObject file = this.processingEnv.getFiler()
.createResource(StandardLocation.CLASS_OUTPUT, "", PROPERTIES_PATH);
OutputStream outputStream = file.openOutputStream();
try {
try (OutputStream outputStream = file.openOutputStream()) {
this.properties.store(outputStream, null);
}
finally {
outputStream.close();
}
}
}

View File

@@ -62,15 +62,11 @@ public class TestConditionMetadataAnnotationProcessor
if (!file.exists()) {
return null;
}
FileInputStream inputStream = new FileInputStream(file);
try {
try (FileInputStream inputStream = new FileInputStream(file)) {
Properties properties = new Properties();
properties.load(inputStream);
return properties;
}
finally {
inputStream.close();
}
}
}