UF.ZIP

UF (Use Freed) issues are reported when there is an attempt to use resources after they were released. The UF.ZIP warning indicates an attempt to use a ZipFile after it was closed.

Example 1

Copy
     public static final void copy(InputStream in, OutputStream out) throws IOException {
         byte[] buffer = new byte[1024];
         int len;
 
         while ((len = in.read(buffer)) >= 0) {
             out.write(buffer, 0, len);
         }
 
         in.close();
         out.close();
     }
 
     public final void unzip(final ZipFile zipFile) {
         Enumeration entries;
         entries = zipFile.entries();
 
         try {
             while (entries.hasMoreElements()) {
                 ZipEntry entry = (ZipEntry) entries.nextElement();
 
                 if (entry.isDirectory()) {
                     final File dir = new File(entry.getName());
                     dir.mkdir();
                 } else {
                     try {
                         copy(zipFile.getInputStream(entry), new FileOutputStream(entry.getName()));
                     } catch (IOException e) {
                         zipFile.close();
                     }
                 }
             }
 
             zipFile.close();
         } catch (IOException e) {
             // do nothing
         }
     }

UF.ZIP is reported for the snippet on line 43: 'zipFile' is closed on line 45 in case of an IOException, but there will be an attempt to access 'zipFile' on the next iteration of the cycle.