mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Use try-with-resources statements
See gh-26449
This commit is contained in:
parent
32d378a348
commit
5ba9db391f
@ -172,13 +172,9 @@ class HandlerTests {
|
||||
TestJarCreator.createTestJar(testJar);
|
||||
URL url = new URL(null, "jar:" + testJar.toURI().toURL() + "!/nested.jar!/3.dat", this.handler);
|
||||
JarURLConnection connection = (JarURLConnection) url.openConnection();
|
||||
JarFile jarFile = JarFileWrapper.unwrap(connection.getJarFile());
|
||||
try {
|
||||
try (JarFile jarFile = JarFileWrapper.unwrap(connection.getJarFile())) {
|
||||
assertThat(jarFile.getRootJarFile().getFile()).isEqualTo(testJar);
|
||||
}
|
||||
finally {
|
||||
jarFile.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -187,13 +183,9 @@ class HandlerTests {
|
||||
TestJarCreator.createTestJar(testJar);
|
||||
URL url = new URL(null, "jar:" + testJar.toURI().toURL() + "!/nested.jar!/3.dat", this.handler);
|
||||
JarURLConnection connection = (JarURLConnection) url.openConnection();
|
||||
JarFile jarFile = JarFileWrapper.unwrap(connection.getJarFile());
|
||||
try {
|
||||
try (JarFile jarFile = JarFileWrapper.unwrap(connection.getJarFile())) {
|
||||
assertThat(jarFile.getRootJarFile().getFile()).isEqualTo(testJar);
|
||||
}
|
||||
finally {
|
||||
jarFile.close();
|
||||
}
|
||||
}
|
||||
|
||||
private void assertStandardAndCustomHandlerUrlsAreEqual(String context, String spec) throws MalformedURLException {
|
||||
|
@ -49,20 +49,12 @@ class SampleIntegrationParentApplicationTests {
|
||||
void testVanillaExchange(@TempDir Path temp) throws Exception {
|
||||
File inputDir = new File(temp.toFile(), "input");
|
||||
File outputDir = new File(temp.toFile(), "output");
|
||||
ConfigurableApplicationContext app = SpringApplication.run(SampleParentContextApplication.class,
|
||||
"--service.input-dir=" + inputDir, "--service.output-dir=" + outputDir);
|
||||
try {
|
||||
ConfigurableApplicationContext producer = SpringApplication.run(ProducerApplication.class,
|
||||
"--service.input-dir=" + inputDir, "--service.output-dir=" + outputDir, "World");
|
||||
try {
|
||||
try (ConfigurableApplicationContext app = SpringApplication.run(SampleParentContextApplication.class,
|
||||
"--service.input-dir=" + inputDir, "--service.output-dir=" + outputDir)) {
|
||||
try (ConfigurableApplicationContext producer = SpringApplication.run(ProducerApplication.class,
|
||||
"--service.input-dir=" + inputDir, "--service.output-dir=" + outputDir, "World")) {
|
||||
awaitOutputContaining(outputDir, "Hello World");
|
||||
}
|
||||
finally {
|
||||
producer.close();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
app.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user