@@ -520,8 +520,7 @@ private void load(PropertySourceLoader loader, String location, Profile profile,
520520 }
521521 continue ;
522522 }
523- String name = (location .contains ("*" )) ? "applicationConfig: [" + resource .toString () + "]"
524- : "applicationConfig: [" + location + "]" ;
523+ String name = "applicationConfig: [" + getLocationName (location , resource ) + "]" ;
525524 List <Document > documents = loadDocuments (loader , name , resource );
526525 if (CollectionUtils .isEmpty (documents )) {
527526 if (this .logger .isTraceEnabled ()) {
@@ -557,20 +556,20 @@ private void load(PropertySourceLoader loader, String location, Profile profile,
557556 }
558557 }
559558
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+
560569 private Resource [] getResources (String location ) {
561570 try {
562571 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 );
574573 }
575574 return new Resource [] { this .resourceLoader .getResource (location ) };
576575 }
@@ -579,6 +578,20 @@ private Resource[] getResources(String location) {
579578 }
580579 }
581580
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+
582595 private void addIncludedProfiles (Set <Profile > includeProfiles ) {
583596 LinkedList <Profile > existingProfiles = new LinkedList <>(this .profiles );
584597 this .profiles .clear ();
0 commit comments