Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/242#discussion_r70156846
  
    --- Diff: 
core/src/main/java/org/apache/brooklyn/util/core/ClassLoaderUtils.java ---
    @@ -136,6 +143,33 @@ public ClassLoaderUtils(Class<?> callingClass, 
@Nullable ManagementContext mgmt)
          * {@link #WHITE_LIST_KEY}, defaulting to all {@code 
org.apache.brooklyn.*} bundles.
          */
         public Class<?> loadClass(String name) throws ClassNotFoundException {
    +        Class<?> cls = load(name, ClassLoaderDispatcher.INSTANCE);
    +        if (cls != null) {
    +            return cls;
    +        } else {
    +            throw new ClassNotFoundException("Class " + name + " not found 
on the application class path, nor in the bundle white list.");
    +        }
    +    }
    +
    +    public Class<?> loadClass(String symbolicName, @Nullable String 
version, String className) throws ClassNotFoundException {
    +        Class<?> ret = tryLoadFromBundle(ClassLoaderDispatcher.INSTANCE, 
symbolicName, version, className);
    +        if (ret != null) {
    +            return ret;
    +        } else {
    +            // TODO Could loose useful information from the original 
exception like wiring info.
    +            throw new ClassNotFoundException("Class " + className + " 
could not be loaded from bundle " + toBundleString(symbolicName, version));
    +        }
    +    }
    +
    +    public URL getResource(String name) {
    +        return load(name, ResourceLoaderDispatcher.INSTANCE);
    +    }
    +
    +    public Iterable<URL> getResources(String name) {
    +        return load(name, MultipleResourceLoaderDispatcher.INSTANCE);
    --- End diff --
    
    The contract of `getResources(name)` is that it "finds all the resources 
with the given name". Does that mean we should not terminate the search in he 
first bundle/loader that we find something, but instead search the other places 
as well?!
    
    Also I think that load(String, LoaderDispatcher) just does a null check. So 
if MultipleResourceLoaderDispatcher returns an empty Iterable, then we'd 
terminate the search early.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to