Commit 1fe9066b authored by Andy Wilkinson's avatar Andy Wilkinson

Use fixed name for SpringApplication command line args property source

Closes gh-8680
parent 4a030d5a
......@@ -490,7 +490,7 @@ public class SpringApplication {
PropertySource<?> source = sources.get(name);
CompositePropertySource composite = new CompositePropertySource(name);
composite.addPropertySource(new SimpleCommandLinePropertySource(
name + "-" + args.hashCode(), args));
"springApplicationCommandLineArgs", args));
composite.addPropertySource(source);
sources.replace(name, composite);
}
......
......@@ -497,6 +497,15 @@ public class SpringApplicationTests {
assertThat(environment.getProperty("bar")).isEqualTo("foo");
// New command line properties take precedence
assertThat(environment.getProperty("foo")).isEqualTo("bar");
CompositePropertySource composite = (CompositePropertySource) environment
.getPropertySources().get("commandLineArgs");
assertThat(composite.getPropertySources()).hasSize(2);
assertThat(composite.getPropertySources()).first().matches(
(source) -> source.getName().equals("springApplicationCommandLineArgs"),
"is named springApplicationCommandLineArgs");
assertThat(composite.getPropertySources()).element(1).matches(
(source) -> source.getName().equals("commandLineArgs"),
"is named commandLineArgs");
}
@Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment