he1l0world commented on code in PR #11048:
URL: https://github.com/apache/cloudstack/pull/11048#discussion_r3964892954
##########
framework/spring/module/src/main/java/org/apache/cloudstack/spring/module/model/impl/DefaultModuleDefinitionSet.java:
##########
@@ -310,24 +314,36 @@ public Map<String, ApplicationContext> getContextMap() {
@Override
public Resource[] getConfigResources(String name) {
- Set<Resource> resources = new LinkedHashSet<Resource>();
-
- ModuleDefinition original = null;
- ModuleDefinition def = original = modules.get(name);
-
- if (def == null)
+ ModuleDefinition def = modules.get(name);
+ if (def == null) {
return new Resource[] {};
+ }
+
+ Set<Resource> resources = new LinkedHashSet<>();
resources.addAll(def.getContextLocations());
- while (def != null) {
- resources.addAll(def.getInheritableContextLocations());
- def = modules.get(def.getParentName());
+ resources.addAll(collectInheritedResources(def));
+
+ resources.addAll(def.getOverrideContextLocations());
+
+ return resources.toArray(Resource[]::new);
+ }
+
+ private Set<Resource> collectInheritedResources(final ModuleDefinition
def) {
+ if (def == null) {
+ return Collections.emptySet();
}
- resources.addAll(original.getOverrideContextLocations());
+ final Set<Resource> cachedResources =
inheritedConfigResourcesMap.get(def.getName());
+ if (cachedResources != null) {
+ return cachedResources;
+ }
Review Comment:
Thanks @DaanHoogland, that makes sense! I'll close this for now since it's
only single-threaded use cases here, but we can definitely revisit if access
patterns change in the future.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]