GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Resource Leaks in processing/app/Util.java · Issue #1432 · processing/processing4 Closed DescriptionDebugging:Hello, I was looking around the codebase for the sake of getting familiar with, where i noticed a couple problematic resource usage implementations that do not guarantee closure with either finally or encompassing with try (). Examples:static public void unzip(File zipFile, File dest) throws IOException { FileInputStream fis = new FileInputStream(zipFile); CheckedInputStream checksum = new CheckedInputStream(fis, new Adler32()); ZipInputStream zis = new ZipInputStream(new BufferedInputStream(checksum)); ZipEntry entry; while ((entry = zis.getNextEntry()) != null) { final String name = entry.getName(); if (!name.startsWith(("__MACOSX"))) { File currentFile = new File(dest, name); if (entry.isDirectory()) { currentFile.mkdirs(); } else { File parentDir = currentFile.getParentFile(); // Sometimes the directory entries aren't already created if (!parentDir.exists()) { parentDir.mkdirs(); } currentFile.createNewFile(); unzipEntry(zis, currentFile); } } } } ZipInputStream, CheckedInputStream, and FileInputStream are never closed. i think this may also contribute to update issues if there are any, as any crash may lock the temporary zip file, preventing its deletion. A simple solution would be:public static void unzip(File zipFile, File dest) throws IOException { try (ZipInputStream zis = new ZipInputStream( new BufferedInputStream( new CheckedInputStream( new FileInputStream(zipFile), new Adler32())))) { ZipEntry entry; while ((entry = zis.getNextEntry()) != null) { //rest of code } } } this way all three underlying streams are closed automatically, even on exception. Willing to work on this?If i may, i'd be more than happy to be assigned to this issue as my first contribution to this codebase! Activity
MetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |