Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2017-08-18 12:15:42 +0000
committerAlexander Kurtakov2017-08-18 12:15:42 +0000
commit191fe70301dcd993856a1869c08ecb22a4bafa84 (patch)
tree2c4671f56e96c2519d7f28afccfbdff463b2bbbd /bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
parent08b1c52015387463c263add217c6807d0aec7dba (diff)
downloadrt.equinox.p2-191fe70301dcd993856a1869c08ecb22a4bafa84.tar.gz
rt.equinox.p2-191fe70301dcd993856a1869c08ecb22a4bafa84.tar.xz
rt.equinox.p2-191fe70301dcd993856a1869c08ecb22a4bafa84.zip
Bug 521114 - Move p2 engine to Java 8
Bump minor version, try-with-resources, remove duplicate type declarations. Change-Id: I33bc01cfef2272e444614f92fb4fcc313bffbe91 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java')
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java22
1 files changed, 2 insertions, 20 deletions
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
index e8ae44844..328991eae 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
@@ -1054,19 +1054,10 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
lastAccessedProperties = new ProfileStateProperties(id, file, properties);
return properties;
}
- InputStream input = null;
- try {
- input = new BufferedInputStream(new FileInputStream(file));
+ try (InputStream input = new BufferedInputStream(new FileInputStream(file))) {
properties.load(input);
} catch (IOException e) {
throw new ProvisionException(new Status(IStatus.ERROR, EngineActivator.ID, Messages.SimpleProfileRegistry_States_Error_Reading_File, e));
- } finally {
- if (input != null)
- try {
- input.close();
- } catch (IOException e) {
- // Ignore
- }
}
//cache the value before we return
@@ -1083,22 +1074,13 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
File profileDirectory = getProfileFolder(id);
File file = new File(profileDirectory, PROFILE_PROPERTIES_FILE);
- OutputStream output = null;
Properties prunedProperties = properties;
- try {
- output = new BufferedOutputStream(new FileOutputStream(file));
+ try (OutputStream output = new BufferedOutputStream(new FileOutputStream(file));) {
prunedProperties = pruneStateProperties(id, properties);
prunedProperties.store(output, null);
output.flush();
} catch (IOException e) {
return new Status(IStatus.ERROR, EngineActivator.ID, Messages.SimpleProfileRegistry_States_Error_Writing_File, e);
- } finally {
- try {
- if (output != null)
- output.close();
- } catch (IOException e) {
- // ignore
- }
}
// cache the value
lastAccessedProperties = new ProfileStateProperties(id, file, prunedProperties);

Back to the top