|
20 | 20 | import java.io.FileOutputStream;
|
21 | 21 | import java.io.IOException;
|
22 | 22 | import java.io.InputStream;
|
23 |
| -import java.net.MalformedURLException; |
24 | 23 | import java.net.URL;
|
25 | 24 | import java.net.URLClassLoader;
|
26 | 25 | import java.nio.charset.StandardCharsets;
|
@@ -219,17 +218,18 @@ void proxyOnClassFromSystemClassLoaderDoesNotYieldWarning() {
|
219 | 218 | }
|
220 | 219 |
|
221 | 220 | @Test
|
222 |
| - void packagePrivateClassLoadedByParentClassLoaderCanBeProxied() throws MalformedURLException { |
223 |
| - new ApplicationContextRunner() |
224 |
| - .withClassLoader(new RestartClassLoader(ExampleTransactional.class.getClassLoader(), |
225 |
| - new URL[] { this.sampleJarFile.toURI().toURL() }, this.updatedFiles)) |
226 |
| - .withUserConfiguration(ProxyConfiguration.class).run((context) -> { |
227 |
| - assertThat(context).hasNotFailed(); |
228 |
| - ExampleTransactional transactional = context.getBean(ExampleTransactional.class); |
229 |
| - assertThat(AopUtils.isCglibProxy(transactional)).isTrue(); |
230 |
| - assertThat(transactional.getClass().getClassLoader()) |
231 |
| - .isEqualTo(ExampleTransactional.class.getClassLoader()); |
232 |
| - }); |
| 221 | + void packagePrivateClassLoadedByParentClassLoaderCanBeProxied() throws IOException { |
| 222 | + try (RestartClassLoader restartClassLoader = new RestartClassLoader(ExampleTransactional.class.getClassLoader(), |
| 223 | + new URL[] { this.sampleJarFile.toURI().toURL() }, this.updatedFiles)) { |
| 224 | + new ApplicationContextRunner().withClassLoader(restartClassLoader) |
| 225 | + .withUserConfiguration(ProxyConfiguration.class).run((context) -> { |
| 226 | + assertThat(context).hasNotFailed(); |
| 227 | + ExampleTransactional transactional = context.getBean(ExampleTransactional.class); |
| 228 | + assertThat(AopUtils.isCglibProxy(transactional)).isTrue(); |
| 229 | + assertThat(transactional.getClass().getClassLoader()) |
| 230 | + .isEqualTo(ExampleTransactional.class.getClassLoader()); |
| 231 | + }); |
| 232 | + } |
233 | 233 | }
|
234 | 234 |
|
235 | 235 | private String readString(InputStream in) throws IOException {
|
|
0 commit comments