diff --git a/plugins/org.eclipse.embedcdt.debug.gdbjtag.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.embedcdt.debug.gdbjtag.core/META-INF/MANIFEST.MF index 74c7ac14e..afc37451b 100644 --- a/plugins/org.eclipse.embedcdt.debug.gdbjtag.core/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.embedcdt.debug.gdbjtag.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %bundle.name Bundle-SymbolicName: org.eclipse.embedcdt.debug.gdbjtag.core;singleton:=true -Bundle-Version: 5.2.2.qualifier +Bundle-Version: 5.2.3.qualifier Bundle-Activator: org.eclipse.embedcdt.internal.debug.gdbjtag.core.Activator Require-Bundle: org.eclipse.embedcdt.core;bundle-version="6.7.0", org.eclipse.embedcdt.debug.core;bundle-version="2.0.0", diff --git a/plugins/org.eclipse.embedcdt.debug.gdbjtag.core/src/org/eclipse/embedcdt/debug/gdbjtag/core/datamodel/SvdUtils.java b/plugins/org.eclipse.embedcdt.debug.gdbjtag.core/src/org/eclipse/embedcdt/debug/gdbjtag/core/datamodel/SvdUtils.java index f087bbc75..2c4f75592 100644 --- a/plugins/org.eclipse.embedcdt.debug.gdbjtag.core/src/org/eclipse/embedcdt/debug/gdbjtag/core/datamodel/SvdUtils.java +++ b/plugins/org.eclipse.embedcdt.debug.gdbjtag.core/src/org/eclipse/embedcdt/debug/gdbjtag/core/datamodel/SvdUtils.java @@ -435,35 +435,34 @@ public static Leaf getTree(IPath path) throws CoreException { out.println("Decompressing zipped SVD file \"" + path.toOSString() + "\"..."); // This is the signature of ZIP files. - ZipInputStream zipInput; - zipInput = new ZipInputStream(new FileInputStream(file)); - // Get the zipped file list entry - ZipEntry zipEntry = zipInput.getNextEntry(); - while (zipEntry != null) { - if (!zipEntry.isDirectory()) { - String fileName = zipEntry.getName(); - - File outFile = PacksStorage.getCachedFileObject(fileName); - if (!outFile.getParentFile().exists()) { - outFile.getParentFile().mkdirs(); + try (ZipInputStream zipInput = new ZipInputStream(new FileInputStream(file))) { + // Get the zipped file list entry + ZipEntry zipEntry = zipInput.getNextEntry(); + while (zipEntry != null) { + if (!zipEntry.isDirectory()) { + String fileName = zipEntry.getName(); + + File outFile = PacksStorage.getCachedFileObject(fileName); + if (!outFile.getParentFile().exists()) { + outFile.getParentFile().mkdirs(); + } + out.println("Writing \"" + outFile + "\"..."); + + OutputStream output = new FileOutputStream(outFile); + + byte[] buf = new byte[1024]; + int bytesRead; + while ((bytesRead = zipInput.read(buf)) > 0) { + output.write(buf, 0, bytesRead); + } + output.close(); + actualPath = new Path(outFile.getAbsolutePath()); + break; } - out.println("Writing \"" + outFile + "\"..."); - - OutputStream output = new FileOutputStream(outFile); - - byte[] buf = new byte[1024]; - int bytesRead; - while ((bytesRead = zipInput.read(buf)) > 0) { - output.write(buf, 0, bytesRead); - } - output.close(); - actualPath = new Path(outFile.getAbsolutePath()); - break; + zipEntry = zipInput.getNextEntry(); } - zipEntry = zipInput.getNextEntry(); + zipInput.closeEntry(); } - zipInput.closeEntry(); - zipInput.close(); file = actualPath.toFile(); reader = new FileReader(file); diff --git a/plugins/org.eclipse.embedcdt.packs.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.embedcdt.packs.core/META-INF/MANIFEST.MF index b69e913c5..d26502d7f 100644 --- a/plugins/org.eclipse.embedcdt.packs.core/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.embedcdt.packs.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %bundle.name Bundle-SymbolicName: org.eclipse.embedcdt.packs.core;singleton:=true -Bundle-Version: 3.1.3.qualifier +Bundle-Version: 3.1.4.qualifier Bundle-Activator: org.eclipse.embedcdt.internal.packs.core.Activator Bundle-RequiredExecutionEnvironment: JavaSE-11 Bundle-ActivationPolicy: lazy diff --git a/plugins/org.eclipse.embedcdt.packs.core/src/org/eclipse/embedcdt/packs/core/jobs/InstallJob.java b/plugins/org.eclipse.embedcdt.packs.core/src/org/eclipse/embedcdt/packs/core/jobs/InstallJob.java index 888063dd1..b95f97a11 100644 --- a/plugins/org.eclipse.embedcdt.packs.core/src/org/eclipse/embedcdt/packs/core/jobs/InstallJob.java +++ b/plugins/org.eclipse.embedcdt.packs.core/src/org/eclipse/embedcdt/packs/core/jobs/InstallJob.java @@ -333,73 +333,72 @@ private boolean unzip(File archiveFile, IPath destRelativePath) throws IOExcepti boolean result = true; // Get the zip file content. - ZipInputStream zipInput; - zipInput = new ZipInputStream(new FileInputStream(archiveFile)); - // Get the zipped file list entry - ZipEntry zipEntry = zipInput.getNextEntry(); + try (ZipInputStream zipInput = new ZipInputStream(new FileInputStream(archiveFile))) { + // Get the zipped file list entry + ZipEntry zipEntry = zipInput.getNextEntry(); - int countFiles = 0; - int countBytes = 0; - while (zipEntry != null && (result == true)) { + int countFiles = 0; + int countBytes = 0; + while (zipEntry != null && (result == true)) { - // Skip the folder definitions, we automatically create them. - if (!zipEntry.isDirectory()) { + // Skip the folder definitions, we automatically create them. + if (!zipEntry.isDirectory()) { - String fileName = zipEntry.getName(); + String fileName = zipEntry.getName(); - IPath path = destRelativePath.append(fileName); - File outFile = PacksStorage.getFileObject(path.toString()); - if (!outFile.getParentFile().exists()) { - outFile.getParentFile().mkdirs(); - } - fOut.println("Writing \"" + outFile + "\"..."); - - OutputStream output = new FileOutputStream(outFile); - - byte[] buf = new byte[1024]; - int bytesRead; - while ((bytesRead = zipInput.read(buf)) > 0) { + IPath path = destRelativePath.append(fileName); + File outFile = PacksStorage.getFileObject(path.toString()); + if (!outFile.getParentFile().exists()) { + outFile.getParentFile().mkdirs(); + } + fOut.println("Writing \"" + outFile + "\"..."); + + OutputStream output = new FileOutputStream(outFile); + + byte[] buf = new byte[1024]; + int bytesRead; + while ((bytesRead = zipInput.read(buf)) > 0) { + try { + output.write(buf, 0, bytesRead); + } catch (IOException e) { + String msg = e.getMessage() + ", file: " + outFile.getName(); + fOut.println("Error: " + msg); + DataUtils.reportError(msg); + + result = false; + break; + } + countBytes += bytesRead; + } try { - output.write(buf, 0, bytesRead); + output.close(); } catch (IOException e) { String msg = e.getMessage() + ", file: " + outFile.getName(); fOut.println("Error: " + msg); DataUtils.reportError(msg); result = false; - break; } - countBytes += bytesRead; - } - try { - output.close(); - } catch (IOException e) { - String msg = e.getMessage() + ", file: " + outFile.getName(); - fOut.println("Error: " + msg); - DataUtils.reportError(msg); - - result = false; - } - outFile.setReadOnly(); - ++countFiles; + outFile.setReadOnly(); + ++countFiles; - } + } - zipEntry = zipInput.getNextEntry(); - } + zipEntry = zipInput.getNextEntry(); + } - fMonitor.worked(1); + fMonitor.worked(1); - zipInput.closeEntry(); - zipInput.close(); - if (countBytes > 0) { - fOut.println(countFiles + " files written, " + StringUtils.convertSizeToString(countBytes) + "."); - } else { - fOut.println("No files written."); - result = false; + zipInput.closeEntry(); + if (countBytes > 0) { + fOut.println(countFiles + " files written, " + StringUtils.convertSizeToString(countBytes) + "."); + } else { + fOut.println("No files written."); + result = false; + } + return result; } - return result; } }