Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2017-12-14 07:19:20 -0500
committerAlexander Kurtakov2017-12-14 09:15:07 -0500
commit9b4f5003d023e28cea08b608f76ef953c065e255 (patch)
tree57eb69f574bec5c85908591799ce0d70622181e0 /bundles
parentfc3cfaf394ac7a6887da4bfc00caa3f50baf3a64 (diff)
downloadrt.equinox.framework-9b4f5003d023e28cea08b608f76ef953c065e255.tar.gz
rt.equinox.framework-9b4f5003d023e28cea08b608f76ef953c065e255.tar.xz
rt.equinox.framework-9b4f5003d023e28cea08b608f76ef953c065e255.zip
Silence resource warnings and handle zipfile with try-with-resources to ensure it's closed. Change-Id: Ic2d0601029fc03770920b52a28c0c2fa055a037d Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java61
1 files changed, 33 insertions, 28 deletions
diff --git a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java
index dff5953c2..72c08451a 100644
--- a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java
+++ b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java
@@ -647,6 +647,7 @@ public class Main {
parent = appCL.getParent();
} else if (PARENT_CLASSLOADER_CURRENT.equalsIgnoreCase(type))
parent = this.getClass().getClassLoader();
+ @SuppressWarnings("resource")
URLClassLoader loader = new StartupClassLoader(bootPath, parent);
Class<?> clazz = loader.loadClass(STARTER);
Method method = clazz.getDeclaredMethod("run", String[].class, Runnable.class); //$NON-NLS-1$
@@ -2377,39 +2378,43 @@ public class Main {
if (!clean)
return splash.getAbsolutePath();
}
- ZipFile file;
- try {
- file = new ZipFile(jarPath);
+
+ try (ZipFile file = new ZipFile(jarPath)) {
+ ZipEntry entry = file.getEntry(jarEntry.replace(File.separatorChar, '/'));
+ if (entry == null)
+ return null;
+ InputStream input = null;
+ try {
+ input = file.getInputStream(entry);
+ } catch (IOException e) {
+ log("Exception opening splash: " + entry.getName() + " in JAR file: " + jarPath); //$NON-NLS-1$ //$NON-NLS-2$
+ log(e);
+ return null;
+ }
+ new File(splash.getParent()).mkdirs();
+ OutputStream output;
+ try {
+ output = new BufferedOutputStream(new FileOutputStream(splash));
+ } catch (FileNotFoundException e) {
+ try {
+ input.close();
+ } catch (IOException e1) {
+ // ignore
+ }
+ return null;
+ }
+ transferStreams(input, output);
+ try {
+ file.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return splash.exists() ? splash.getAbsolutePath() : null;
} catch (IOException e) {
log("Exception looking for " + jarEntry + " in JAR file: " + jarPath); //$NON-NLS-1$ //$NON-NLS-2$
log(e);
return null;
}
- ZipEntry entry = file.getEntry(jarEntry.replace(File.separatorChar, '/'));
- if (entry == null)
- return null;
- InputStream input = null;
- try {
- input = file.getInputStream(entry);
- } catch (IOException e) {
- log("Exception opening splash: " + entry.getName() + " in JAR file: " + jarPath); //$NON-NLS-1$ //$NON-NLS-2$
- log(e);
- return null;
- }
- new File(splash.getParent()).mkdirs();
- OutputStream output;
- try {
- output = new BufferedOutputStream(new FileOutputStream(splash));
- } catch (FileNotFoundException e) {
- try {
- input.close();
- } catch (IOException e1) {
- // ignore
- }
- return null;
- }
- transferStreams(input, output);
- return splash.exists() ? splash.getAbsolutePath() : null;
}
/*

Back to the top