Maintain classpath order in PropertiesLauncher

I think this is safe, judging by the integration tests, but I'm not
putting it in 1.2.x until we've had some feedback on it. The
integration tests actually had a bug that was masking this problem
because they were merging Properties from the whole classpath instead
of picking the first available resource (which is generally what
we do in Spring Boot applications for application.properties for
instance).

Fixes gh-3048
This commit is contained in:
Dave Syer
2015-07-14 10:19:47 +01:00
parent a158baf50f
commit bfa816f2a3
6 changed files with 18 additions and 8 deletions

View File

@@ -134,6 +134,17 @@ public class PropertiesLauncherTests {
waitFor("Hello World");
}
@Test
public void testUserSpecifiedClassPathOrder() throws Exception {
System.setProperty("loader.path", "more-jars/app.jar,jars/app.jar");
System.setProperty("loader.classLoader", URLClassLoader.class.getName());
PropertiesLauncher launcher = new PropertiesLauncher();
assertEquals("[more-jars/app.jar, jars/app.jar]",
ReflectionTestUtils.getField(launcher, "paths").toString());
launcher.launch(new String[0]);
waitFor("Hello Other World");
}
@Test
public void testCustomClassLoaderCreation() throws Exception {
System.setProperty("loader.classLoader", TestLoader.class.getName());