RLK.ZIPRLK (Resource Leak) issues are reported when resources are allocated but not properly disposed after use. Failing to properly dispose a resource can lead to such problems as:
An RLK.ZIP warning indicates that a ZipFile object is not disposed on exit. Vulnerability and riskResources such as streams, connections and graphic objects must be explicitly closed. The close operation can unblock transactions or flush file changes in the file system. While a resource will eventually be closed by the garbage collector, resource exhaustion can occur before garbage collection starts. Depending on the nature of the resource, various exceptions will be thrown on a failed attempt to allocate another resource, for example: java.io.FileNotFoundException: Too many open files or too many database connections. Mitigation and preventionExplicitly close all resources that have the close method, even those that you think are not doing anything significant. Future code changes will then be safe from such errors. Example 118 public static Collection<String> findDeprecated(final Properties properties) throws IOException { 19 final List<String> list = new ArrayList<String>(); 20 final ZipFile doczipFile = new ZipFile(properties.getProperty("doczip")); 21 22 final Enumeration<? extends ZipEntry> entries = doczipFile.entries(); 23 while (entries.hasMoreElements()) { 24 final ZipEntry entry = entries.nextElement(); 25 final String name = entry.getName(); 26 if (name.matches(".*_DEPRECATED_.*")) { 27 list.add(name); 28 } 29 } 30 31 return list; 32 } RLK.ZIP is reported for the snippet on line 20: Zip file 'doczipFile' is not closed on exit. ExtensionThis checker can be extended through the Klocwork knowledge base. See Tuning Java analysis for more information. |