Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal')
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java2
2 files changed, 3 insertions, 21 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);
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java
index 877007183..85708904f 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java
@@ -163,7 +163,7 @@ public class SurrogateProfileHandler implements ISurrogateProfileHandler {
final Profile profile = (Profile) registry.getProfile(id, currentTimestamp);
if (profile != null)
- cachedProfile = new SoftReference<IProfile>(profile);
+ cachedProfile = new SoftReference<>(profile);
if (!EngineActivator.EXTENDED) {
return profile;

Back to the top