DaanHoogland commented on code in PR #11048:
URL: https://github.com/apache/cloudstack/pull/11048#discussion_r3958167559


##########
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:
   hee @he1l0world , I think using `ConcurrentHashMap` is meant by this 
comment. I am not sure why the comment is generated, but I expect because the 
reference to the internal set is returned to unknown callers to be manipulated 
at unpredictable moments from the point of view of this code. I think it cannot 
hurt to use it. But if you can argue it will never be used delayed, go ahead 
and close it.



-- 
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]

Reply via email to