@@ -520,8 +520,7 @@ private void load(PropertySourceLoader loader, String location, Profile profile,
520
520
}
521
521
continue ;
522
522
}
523
- String name = (location .contains ("*" )) ? "applicationConfig: [" + resource .toString () + "]"
524
- : "applicationConfig: [" + location + "]" ;
523
+ String name = "applicationConfig: [" + getLocationName (location , resource ) + "]" ;
525
524
List <Document > documents = loadDocuments (loader , name , resource );
526
525
if (CollectionUtils .isEmpty (documents )) {
527
526
if (this .logger .isTraceEnabled ()) {
@@ -557,20 +556,20 @@ private void load(PropertySourceLoader loader, String location, Profile profile,
557
556
}
558
557
}
559
558
559
+ private String getLocationName (String location , Resource resource ) {
560
+ if (!location .contains ("*" )) {
561
+ return location ;
562
+ }
563
+ if (resource instanceof FileSystemResource ) {
564
+ return ((FileSystemResource ) resource ).getPath ();
565
+ }
566
+ return resource .getDescription ();
567
+ }
568
+
560
569
private Resource [] getResources (String location ) {
561
570
try {
562
571
if (location .contains ("*" )) {
563
- String directoryPath = location .substring (0 , location .indexOf ("*/" ));
564
- String fileName = location .substring (location .lastIndexOf ("/" ) + 1 );
565
- Resource resource = this .resourceLoader .getResource (directoryPath );
566
- File [] files = resource .getFile ().listFiles (File ::isDirectory );
567
- if (files != null ) {
568
- Arrays .sort (files , FILE_COMPARATOR );
569
- return Arrays .stream (files ).map ((file ) -> file .listFiles ((dir , name ) -> name .equals (fileName )))
570
- .filter (Objects ::nonNull ).flatMap ((Function <File [], Stream <File >>) Arrays ::stream )
571
- .map (FileSystemResource ::new ).toArray (Resource []::new );
572
- }
573
- return EMPTY_RESOURCES ;
572
+ return getResourcesFromPatternLocation (location );
574
573
}
575
574
return new Resource [] { this .resourceLoader .getResource (location ) };
576
575
}
@@ -579,6 +578,20 @@ private Resource[] getResources(String location) {
579
578
}
580
579
}
581
580
581
+ private Resource [] getResourcesFromPatternLocation (String location ) throws IOException {
582
+ String directoryPath = location .substring (0 , location .indexOf ("*/" ));
583
+ String fileName = location .substring (location .lastIndexOf ("/" ) + 1 );
584
+ Resource resource = this .resourceLoader .getResource (directoryPath );
585
+ File [] files = resource .getFile ().listFiles (File ::isDirectory );
586
+ if (files != null ) {
587
+ Arrays .sort (files , FILE_COMPARATOR );
588
+ return Arrays .stream (files ).map ((file ) -> file .listFiles ((dir , name ) -> name .equals (fileName )))
589
+ .filter (Objects ::nonNull ).flatMap ((Function <File [], Stream <File >>) Arrays ::stream )
590
+ .map (FileSystemResource ::new ).toArray (Resource []::new );
591
+ }
592
+ return EMPTY_RESOURCES ;
593
+ }
594
+
582
595
private void addIncludedProfiles (Set <Profile > includeProfiles ) {
583
596
LinkedList <Profile > existingProfiles = new LinkedList <>(this .profiles );
584
597
this .profiles .clear ();
0 commit comments