JOL: ObjectShapes.processJAR should close resources properly

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • None
    • Affects Version/s: None
    • Component/s: tools
    • jol

      SonarCloud instance reports the failures here:
       "Use try-with-resources or close this "URLClassLoader" in a "finally" clause."
       "Use try-with-resources or close this "JarFile" in a "finally" clause."

          private Multiset<String> processJAR(String jarName) {
              Multiset<String> shapes = new Multiset<>();
              try {
                  URLClassLoader cl = URLClassLoader.newInstance(new URL[]{new URL("jar:file:" + jarName + "!/")});
                 JarFile jarFile = new JarFile(jarName);

            Assignee:
            Aleksey Shipilev
            Reporter:
            Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: