Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-1062

ProjectClassLoader.getResources(String) does not work correctly

    XMLWordPrintable

Details

    • NEW
    • NEW

    Description

      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

      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);
              }
          }
      
      }
      

      Attachments

        Issue Links

          Activity

            People

              psiroky_jira Petr Široký (Inactive)
              gdesmet@redhat.com Geoffrey De Smet (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: