Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-05-25 09:17:14 +0000
committerUwe Stieber2012-05-25 09:17:14 +0000
commitc43ff2700cbc527f99e29eefe83f4586a4c2258e (patch)
tree483a85c908377cb05776c68fc06de57bb7f88e85 /target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime
parentcd822fb9e1041dbd02071a04b2b7963ac98be248 (diff)
downloadorg.eclipse.tcf-c43ff2700cbc527f99e29eefe83f4586a4c2258e.tar.gz
org.eclipse.tcf-c43ff2700cbc527f99e29eefe83f4586a4c2258e.tar.xz
org.eclipse.tcf-c43ff2700cbc527f99e29eefe83f4586a4c2258e.zip
Target Explorer: Fix more findbugs warnings
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/AbstractGsonMapPersistenceDelegate.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/internal/PersistenceDelegateBinding.java2
2 files changed, 16 insertions, 8 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/AbstractGsonMapPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/AbstractGsonMapPersistenceDelegate.java
index 095d73e7b..85665f9cb 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/AbstractGsonMapPersistenceDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/AbstractGsonMapPersistenceDelegate.java
@@ -94,10 +94,14 @@ public abstract class AbstractGsonMapPersistenceDelegate extends ExecutableExten
file = path.addFileExtension(getDefaultFileExtension()).toFile();
}
- Writer writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); //$NON-NLS-1$
- Gson gson = new GsonBuilder().setPrettyPrinting().create();
- gson.toJson(toMap(context), Map.class, writer);
- writer.close();
+ Writer writer = null;
+ try {
+ writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); //$NON-NLS-1$
+ Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ gson.toJson(toMap(context), Map.class, writer);
+ } finally {
+ if (writer != null) writer.close();
+ }
}
else if (container instanceof String || String.class.equals(container)) {
Gson gson = new GsonBuilder().create();
@@ -133,9 +137,13 @@ public abstract class AbstractGsonMapPersistenceDelegate extends ExecutableExten
throw new IOException("URI must denote an absolute file path."); //$NON-NLS-1$
}
- Reader reader = new InputStreamReader(new FileInputStream(file), "UTF-8"); //$NON-NLS-1$
- data = gson.fromJson(reader, Map.class);
- reader.close();
+ Reader reader = null;
+ try {
+ reader = new InputStreamReader(new FileInputStream(file), "UTF-8"); //$NON-NLS-1$
+ data = gson.fromJson(reader, Map.class);
+ } finally {
+ if (reader != null) reader.close();
+ }
}
else if (container instanceof String) {
data = gson.fromJson((String)container, Map.class);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/internal/PersistenceDelegateBinding.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/internal/PersistenceDelegateBinding.java
index 20074ab07..9d3bfc863 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/internal/PersistenceDelegateBinding.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/internal/PersistenceDelegateBinding.java
@@ -34,7 +34,7 @@ public class PersistenceDelegateBinding extends ExecutableExtension {
// Initialize the delegate id field by reading the <delegate> extension attribute.
// Throws an exception if the id is empty or null.
delegateId = config != null ? config.getAttribute("delegateId") : null; //$NON-NLS-1$
- if (delegateId == null || (delegateId != null && "".equals(delegateId.trim()))) { //$NON-NLS-1$
+ if (delegateId == null || "".equals(delegateId.trim())) { //$NON-NLS-1$
throw createMissingMandatoryAttributeException("delegateId", config.getContributor().getName()); //$NON-NLS-1$
}

Back to the top