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

@@ -132,7 +132,8 @@ public class EndpointDocumentation {
@Test
public void auditEvents() throws Exception {
this.mockMvc
.perform(get("/application/auditevents").param("after", "2016-11-01T10:00:00+0000")
.perform(get("/application/auditevents")
.param("after", "2016-11-01T10:00:00+0000")
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
.andExpect(status().isOk()).andDo(document("auditevents"));
}
@@ -188,15 +189,11 @@ public class EndpointDocumentation {
}
File file = new File(RESTDOCS_OUTPUT_DIR + "/endpoints.adoc");
file.getParentFile().mkdirs();
PrintWriter writer = new PrintWriter(file, "UTF-8");
try {
try (PrintWriter writer = new PrintWriter(file, "UTF-8")) {
Template template = this.templates.createTemplate(
new File("src/restdoc/resources/templates/endpoints.adoc.tpl"));
template.make(model).writeTo(writer);
}
finally {
writer.close();
}
}
private Collection<? extends MvcEndpoint> getEndpoints() {