Commit 5413ad3c authored by Phillip Webb's avatar Phillip Webb

Merge pull request #12732 from dreis2211

* pr/12732:
  Populate cache in ConfigFileApplicationListener
  Polish
parents 0ec737a0 cc66de28
...@@ -539,12 +539,12 @@ public class ConfigFileApplicationListener ...@@ -539,12 +539,12 @@ public class ConfigFileApplicationListener
private List<Document> loadDocuments(PropertySourceLoader loader, String name, private List<Document> loadDocuments(PropertySourceLoader loader, String name,
Resource resource) throws IOException { Resource resource) throws IOException {
loader.load(name, resource);
DocumentsCacheKey cacheKey = new DocumentsCacheKey(loader, resource); DocumentsCacheKey cacheKey = new DocumentsCacheKey(loader, resource);
List<Document> documents = this.loadDocumentsCache.get(cacheKey); List<Document> documents = this.loadDocumentsCache.get(cacheKey);
if (documents == null) { if (documents == null) {
List<PropertySource<?>> loaded = loader.load(name, resource); List<PropertySource<?>> loaded = loader.load(name, resource);
documents = asDocuments(loaded); documents = asDocuments(loaded);
this.loadDocumentsCache.put(cacheKey, documents);
} }
return documents; return documents;
} }
......
...@@ -41,7 +41,7 @@ public interface PropertySourceLoader { ...@@ -41,7 +41,7 @@ public interface PropertySourceLoader {
/** /**
* Load the resource into one or more property sources. Implementations may either * Load the resource into one or more property sources. Implementations may either
* return a list containing a single source, or in the case of a multi-document format * return a list containing a single source, or in the case of a multi-document format
* such as yaml a source or each document in the resource. * such as yaml a source for each document in the resource.
* @param name the root name of the property source. If multiple documents are loaded * @param name the root name of the property source. If multiple documents are loaded
* an additional suffix should be added to the name for each source loaded. * an additional suffix should be added to the name for each source loaded.
* @param resource the resource to load * @param resource the resource to load
......
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