Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7036583

Invalid File->URL conversion in TestSuite.open0

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • jt4.4.1
    • jt4.4
    • tools
    • None
    • b03
    • generic
    • generic
    • Verified

      See comment inline
      ================
         private static TestSuite open0(File root, Map tsInfo) throws Fault {
              String[] classPath = StringArray.split((String) (tsInfo.get("classpath")));

              ClassLoader cl;
              if (classPath.length == 0)
                  cl = null;
              else {
                  try {
                      File rootDir = (root.isDirectory() ? root : root.getParentFile());
                      URL[] p = new URL[classPath.length];
                      for (int i = 0; i < classPath.length; i++) {
                          String cpi = classPath[i];
                          if (cpi.toLowerCase().startsWith("http:"))
                              p[i] = new URL(cpi);
                          else {
                              File f = new File(cpi);
                              if (!f.isAbsolute())
                                  f = new File(rootDir, cpi);
      // The right conversion would be to call toURI().toURL, not just toURL()
                              p[i] = f.toURL();
                          }
                      }
                      cl = new URLClassLoader(p, TestSuite.class.getClassLoader());
                  }
                  catch (MalformedURLException e) {
                      throw new Fault(i18n, "ts.badClassPath",
                                      new Object[] {root, e.getMessage()});
                  }
              }

            ersh Mikhail Ershov (Inactive)
            bkvartsk Boris Kvartskhava
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: