Skip to content

Commit 7c7daf6

Browse files
committed
Close Writers in StandardWriterResolverTests
The unclosed writers were preventing clean up of the JUnit-managed temporary directory. See gh-959
1 parent b82451e commit 7c7daf6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

spring-restdocs-core/src/test/java/org/springframework/restdocs/snippet/StandardWriterResolverTests.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ void placeholdersAreResolvedInOperationName() throws IOException {
7878
PlaceholderResolver resolver = mock(PlaceholderResolver.class);
7979
given(resolver.resolvePlaceholder("a")).willReturn("alpha");
8080
given(this.placeholderResolverFactory.create(context)).willReturn(resolver);
81-
Writer writer = this.resolver.resolve("{a}", "bravo", context);
82-
assertSnippetLocation(writer, new File(outputDirectory, "alpha/bravo.adoc"));
81+
try (Writer writer = this.resolver.resolve("{a}", "bravo", context)) {
82+
assertSnippetLocation(writer, new File(outputDirectory, "alpha/bravo.adoc"));
83+
}
8384
}
8485

8586
@Test
@@ -89,8 +90,9 @@ void placeholdersAreResolvedInSnippetName() throws IOException {
8990
PlaceholderResolver resolver = mock(PlaceholderResolver.class);
9091
given(resolver.resolvePlaceholder("b")).willReturn("bravo");
9192
given(this.placeholderResolverFactory.create(context)).willReturn(resolver);
92-
Writer writer = this.resolver.resolve("alpha", "{b}", context);
93-
assertSnippetLocation(writer, new File(outputDirectory, "alpha/bravo.adoc"));
93+
try (Writer writer = this.resolver.resolve("alpha", "{b}", context)) {
94+
assertSnippetLocation(writer, new File(outputDirectory, "alpha/bravo.adoc"));
95+
}
9496
}
9597

9698
private RestDocumentationContext createContext(String outputDir) {

0 commit comments

Comments
 (0)