Skip to content

Commit 5b4f9ed

Browse files
committed
Restore original TCCL in PropertiesLauncherTests
Calling launch of PropertiesLauncherTests sets the thread context class loader to an instance of LaunchedURLClassLoader. To avoid this class loader being used beyond the scope of the test and launcher that created it, this commit updates PropertiesLauncherTests to capture the TCCL before each test and restore it after each test. Closes gh-9378
1 parent 6415828 commit 5b4f9ed

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/PropertiesLauncherTests.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -53,15 +53,19 @@ public class PropertiesLauncherTests {
5353
@Rule
5454
public TemporaryFolder temporaryFolder = new TemporaryFolder();
5555

56+
private ClassLoader contextClassLoader;
57+
5658
@Before
5759
public void setup() throws IOException {
60+
this.contextClassLoader = Thread.currentThread().getContextClassLoader();
5861
MockitoAnnotations.initMocks(this);
5962
System.setProperty("loader.home",
6063
new File("src/test/resources").getAbsolutePath());
6164
}
6265

6366
@After
6467
public void close() {
68+
Thread.currentThread().setContextClassLoader(this.contextClassLoader);
6569
System.clearProperty("loader.home");
6670
System.clearProperty("loader.path");
6771
System.clearProperty("loader.main");

0 commit comments

Comments
 (0)