summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2018-05-02 14:28:11 -0400
committerAlexander Kurtakov2018-05-02 14:28:11 -0400
commit0a65b0630aa9402cdb81505a7b20dd29951b1030 (patch)
tree8447d94f0b9df4bf40cf7a213498727d22c413e6
parent36478e9a778e174d966e22a4bb23d98fdb31af1d (diff)
downloadrt.equinox.p2-0a65b0630aa9402cdb81505a7b20dd29951b1030.zip
rt.equinox.p2-0a65b0630aa9402cdb81505a7b20dd29951b1030.tar.gz
rt.equinox.p2-0a65b0630aa9402cdb81505a7b20dd29951b1030.tar.xz
Change-Id: I1e45a9d05e0c31b4b0e727310d2af56cef670bdf Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/SimpleConfiguratorImpl.java22
-rw-r--r--bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java20
2 files changed, 11 insertions, 31 deletions
diff --git a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/SimpleConfiguratorImpl.java b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/SimpleConfiguratorImpl.java
index 1ab8951..25287b9 100644
--- a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/SimpleConfiguratorImpl.java
+++ b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/SimpleConfiguratorImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2017 IBM Corporation and others.
+ * Copyright (c) 2007, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -150,19 +150,13 @@ public class SimpleConfiguratorImpl implements Configurator {
return result;
Properties p = new Properties();
- InputStream is = null;
- try {
- try {
- is = new BufferedInputStream(new FileInputStream(storedSharedTimestamp));
- p.load(is);
- if (p.get(KEY_BUNDLESINFO_TIMESTAMP) != null) {
- result[0] = Long.valueOf((String) p.get(KEY_BUNDLESINFO_TIMESTAMP)).longValue();
- }
- if (p.get(KEY_EXT_TIMESTAMP) != null) {
- result[1] = Long.valueOf((String) p.get(KEY_EXT_TIMESTAMP)).longValue();
- }
- } finally {
- is.close();
+ try (InputStream is = new BufferedInputStream(new FileInputStream(storedSharedTimestamp))) {
+ p.load(is);
+ if (p.get(KEY_BUNDLESINFO_TIMESTAMP) != null) {
+ result[0] = Long.valueOf((String) p.get(KEY_BUNDLESINFO_TIMESTAMP)).longValue();
+ }
+ if (p.get(KEY_EXT_TIMESTAMP) != null) {
+ result[1] = Long.valueOf((String) p.get(KEY_EXT_TIMESTAMP)).longValue();
}
} catch (IOException e) {
return result;
diff --git a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java
index 19b3d2a..f709807 100644
--- a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java
+++ b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2017 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2007, 2018 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -206,10 +206,9 @@ public class SimpleConfiguratorUtils {
BufferedInputStream bufferedStream = new BufferedInputStream(stream);
String encoding = determineEncoding(bufferedStream);
- BufferedReader r = new BufferedReader(encoding == null ? new InputStreamReader(bufferedStream) : new InputStreamReader(bufferedStream, encoding));
String line;
- try {
+ try (BufferedReader r = new BufferedReader(encoding == null ? new InputStreamReader(bufferedStream) : new InputStreamReader(bufferedStream, encoding));) {
while ((line = r.readLine()) != null) {
line = line.trim();
//ignore any comment or empty lines
@@ -225,12 +224,6 @@ public class SimpleConfiguratorUtils {
if (bundleInfo != null)
bundles.add(bundleInfo);
}
- } finally {
- try {
- r.close();
- } catch (IOException ex) {
- // ignore
- }
}
return bundles;
}
@@ -336,8 +329,7 @@ public class SimpleConfiguratorUtils {
destination = new BufferedOutputStream(destination);
try {
for (int i = 0; i < sources.size(); i++) {
- InputStream source = new BufferedInputStream(sources.get(i));
- try {
+ try (InputStream source = new BufferedInputStream(sources.get(i))) {
byte[] buffer = new byte[8192];
while (true) {
int bytesRead = -1;
@@ -345,12 +337,6 @@ public class SimpleConfiguratorUtils {
break;
destination.write(buffer, 0, bytesRead);
}
- } finally {
- try {
- source.close();
- } catch (IOException e) {
- // ignore
- }
}
}
} finally {