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

JOL: ObjectShapes.processJAR should close resources properly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • None
    • None
    • 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);

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

              Created:
              Updated:
              Resolved: