Hi Jarek, I originally had named it "notFoundResources" and probably should have
left it at that. I'll change it to something less confusing. Thanks for reviewing....
Jarek Gawor wrote:
Can we maybe change the variable name to something else, e.g.
unknownResources? Calling it "knownResources" for resources that are
not found is a little confusing.
Jarek
On Wed, Jan 7, 2009 at 3:56 PM, <mcco...@apache.org> wrote:
Author: mcconne
Date: Wed Jan 7 12:56:39 2009
New Revision: 732486
URL: http://svn.apache.org/viewvc?rev=732486&view=rev
Log:
GERONIMO-4497 Change to prevent repetitive searches for the same (not found)
resource
Modified:
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java
Modified:
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java
URL:
http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java?rev=732486&r1=732485&r2=732486&view=diff
==============================================================================
---
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java
(original)
+++
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java
Wed Jan 7 12:56:39 2009
@@ -60,6 +60,7 @@
private final ClassLoader[] parents;
private final ClassLoadingRules classLoadingRules;
private boolean destroyed = false;
+ private Set<String> knownResources = new HashSet<String>();
// I used this pattern as its temporary and with the static final we get
compile time
// optimizations.
@@ -514,7 +515,7 @@
}
public URL getResource(String name) {
- if (isDestroyed()) {
+ if (isDestroyed() || knownResources.contains(name)) {
return null;
}
@@ -548,7 +549,17 @@
// resource, so we can override now
if (!isDestroyed()) {
// parents didn't have the resource; attempt to load it from my urls
- return findResource(name);
+ URL url = findResource(name);
+ if (url != null) {
+ return url;
+ }
+ }
+
+ //
+ // Resource not found -- no need to search for it again
+ //
+ if (!knownResources.contains(name)) {
+ knownResources.add(name);
}
return null;