[jboss-jira] [JBoss JIRA] (DROOLS-1062) ProjectClassLoader.getResources(String) does not work correctly

Geoffrey De Smet (JIRA) issues at jboss.org
Fri Feb 12 08:53:02 EST 2016


Geoffrey De Smet created DROOLS-1062:
----------------------------------------

             Summary: ProjectClassLoader.getResources(String) does not work correctly
                 Key: DROOLS-1062
                 URL: https://issues.jboss.org/browse/DROOLS-1062
             Project: Drools
          Issue Type: Bug
          Components: core engine
            Reporter: Geoffrey De Smet


ProjectClassLoader.getResource*s*("org/foo") returns an enumeration with 0 elements. That should be 1 element (most of the time anyway, as we don't have split packages).

See screenshot to learn how a getResources(String) should behave


{code}
public class ClassLoaderGetResourcesExperiment {

    public static void main(String[] args) throws IOException {
        ClassLoader classLoader = ClassLoaderGetResourcesExperiment.class.getClassLoader();
        printEnumeration(classLoader, "org/optaplanner/core/experiment");
        printEnumeration(classLoader, "org/optaplanner/core/experiment/sub1");
        printEnumeration(classLoader, "org/optaplanner/core/experiment/sub2");
        printEnumeration(classLoader, "org/optaplanner/core/experiment/sub3");
    }

    public static void printEnumeration(ClassLoader classLoader, String s) throws IOException {
        Enumeration<URL> enumeration = classLoader.getResources(s);
        System.out.println(s);
        System.out.println("================================");
        while (enumeration.hasMoreElements()) {
            Object nextElement = enumeration.nextElement();
            System.out.println("    " + nextElement);
        }
    }

}
{code}



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the jboss-jira mailing list