File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
main/java/org/springframework/boot/context/config
test/java/org/springframework/boot/context/config Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 5454import org .springframework .core .io .Resource ;
5555import org .springframework .core .io .ResourceLoader ;
5656import org .springframework .util .Assert ;
57+ import org .springframework .util .ResourceUtils ;
5758import org .springframework .util .StringUtils ;
5859import org .springframework .validation .BindException ;
5960
@@ -455,10 +456,10 @@ private Set<String> getSearchLocations() {
455456 for (String path : asResolvedSet (
456457 this .environment .getProperty (CONFIG_LOCATION_PROPERTY ), null )) {
457458 if (!path .contains ("$" )) {
458- if (!path .contains (":" )) {
459- path = "file:" + path ;
460- }
461459 path = StringUtils .cleanPath (path );
460+ if (!ResourceUtils .isUrl (path )) {
461+ path = ResourceUtils .FILE_URL_PREFIX + path ;
462+ }
462463 }
463464 locations .add (path );
464465 }
Original file line number Diff line number Diff line change @@ -458,6 +458,16 @@ public void specificResourceDefaultsToFile() throws Exception {
458458 + location + "]" ));
459459 }
460460
461+ @ Test
462+ public void absoluteResourceDefaultsToFile () throws Exception {
463+ String location = new File ("src/test/resources/specificlocation.properties" ).getAbsolutePath ();
464+ EnvironmentTestUtils .addEnvironment (this .environment , "spring.config.location:"
465+ + location );
466+ this .initializer .onApplicationEvent (this .event );
467+ assertThat (this .environment , containsPropertySource ("applicationConfig: [file:"
468+ + location .replace (File .separatorChar , '/' ) + "]" ));
469+ }
470+
461471 @ Test
462472 public void propertySourceAnnotation () throws Exception {
463473 SpringApplication application = new SpringApplication (WithPropertySource .class );
You can’t perform that action at this time.
0 commit comments