Close writer after use in ExtractCommandTests

Update `ExtractCommandTests` so that the writer is closed after the
contents have been written.

See gh-22993
This commit is contained in:
Phillip Webb
2020-08-19 10:25:37 -07:00
parent 0dd38a7264
commit 8722c2c5de

View File

@@ -100,9 +100,9 @@ class ExtractCommandTests {
@Test
void runWithJarFileContainingNoEntriesFails() throws IOException {
File file = new File(this.temp, "empty.jar");
FileWriter writer = new FileWriter(file);
writer.write("text");
writer.flush();
try (FileWriter writer = new FileWriter(file)) {
writer.write("text");
}
given(this.context.getJarFile()).willReturn(file);
given(this.context.getWorkingDir()).willReturn(this.extract);
assertThatIllegalStateException()