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:
@@ -64,13 +64,10 @@ public class MetadataStore {
|
||||
|
||||
public void writeMetadata(ConfigurationMetadata metadata) throws IOException {
|
||||
if (!metadata.getItems().isEmpty()) {
|
||||
OutputStream outputStream = createMetadataResource().openOutputStream();
|
||||
try {
|
||||
try (OutputStream outputStream = createMetadataResource()
|
||||
.openOutputStream()) {
|
||||
new JsonMarshaller().write(metadata, outputStream);
|
||||
}
|
||||
finally {
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -815,13 +815,9 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
}
|
||||
|
||||
private void writeMetadata(File metadataFile, JSONObject metadata) throws Exception {
|
||||
FileWriter writer = new FileWriter(metadataFile);
|
||||
try {
|
||||
try (FileWriter writer = new FileWriter(metadataFile)) {
|
||||
writer.append(metadata.toString(2));
|
||||
}
|
||||
finally {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
private static class AdditionalMetadata {
|
||||
|
||||
Reference in New Issue
Block a user