Spring Boot Version: 3.5.7

Class: org.springframework.boot.context.config.ConfigDataImporter

Method:

private Map<ConfigDataResolutionResult, ConfigData> load(ConfigDataLoaderContext loaderContext,
            List<ConfigDataResolutionResult> candidates) throws IOException {
        Map<ConfigDataResolutionResult, ConfigData> result = new LinkedHashMap<>();
        for (int i = candidates.size() - 1; i >= 0; i--) {
            ConfigDataResolutionResult candidate = candidates.get(i);
            ConfigDataLocation location = candidate.getLocation();
            ConfigDataResource resource = candidate.getResource();
            this.logger.trace(LogMessage.format("Considering resource %s from location %s", resource, location));
            if (resource.isOptional()) {
                this.optionalLocations.add(location);
            }
            if (this.loaded.contains(resource)) {
                this.logger
                    .trace(LogMessage.format("Already loaded resource %s ignoring location %s", resource, location));
                this.loadedLocations.add(location);
            }
            else {
                try {
                    ConfigData loaded = this.loaders.load(loaderContext, resource);
                    if (loaded != null) {
                        this.logger.trace(LogMessage.format("Loaded resource %s from location %s", resource, location));
                        this.loaded.add(resource);
                        this.loadedLocations.add(location);
                        result.put(candidate, loaded);
                    }
                }
                catch (ConfigDataNotFoundException ex) {
                    handle(ex, location, resource);
                }
            }
        }
                //  FIXME
                //  Config file in result has corrent order
                // BUT use unmodifiableMap  convert to UnmodifiableMap will change the order in result
                //  Will cause the configuration items become invalid
        return Collections.unmodifiableMap(result);
    }