Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2017-06-02 16:17:08 -0400
committerTomasz Zarna2017-06-02 16:17:08 -0400
commit1d36545be9f4939c6f1e1310aa2d2fc32f3d2aac (patch)
tree66ae44642d55476cda5ff460c713f14c23c1795c /org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks
parent293e9929537bc7b33959eee01e29d6543c12f7a8 (diff)
downloadorg.eclipse.mylyn.tasks-1d36545be9f4939c6f1e1310aa2d2fc32f3d2aac.tar.gz
org.eclipse.mylyn.tasks-1d36545be9f4939c6f1e1310aa2d2fc32f3d2aac.tar.xz
org.eclipse.mylyn.tasks-1d36545be9f4939c6f1e1310aa2d2fc32f3d2aac.zip
use try-with-resources statement in TaskDataStore
Diffstat (limited to 'org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks')
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataStore.java16
1 files changed, 5 insertions, 11 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataStore.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataStore.java
index 3345be4bc..82485ca5b 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataStore.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataStore.java
@@ -111,20 +111,17 @@ public class TaskDataStore {
}
private TaskDataState readStateInternal(File file, boolean xml11) throws IOException, SAXException {
- ZipInputStream in = new ZipInputStream(new BufferedInputStream(new FileInputStream(file)));
- try {
+ try (ZipInputStream in = new ZipInputStream(new BufferedInputStream(new FileInputStream(file)))) {
in.getNextEntry();
- // bug 268456: When TaskData that contains C0 control characters is written to disk using XML 1.0 reading it back
- // in fails with a SAXException. The XML 1.1 standard allows C0 entities but fails if C1 entities. If C0 control
- // characters are detected while parsing file as XML 1.0 a second attempt is made using XML 1.1. If the file contains
+ // bug 268456: When TaskData that contains C0 control characters is written to disk using XML 1.0 reading it back
+ // in fails with a SAXException. The XML 1.1 standard allows C0 entities but fails if C1 entities. If C0 control
+ // characters are detected while parsing file as XML 1.0 a second attempt is made using XML 1.1. If the file contains
// C0 and C1 control characters reading will fail regardless.
if (xml11) {
return externalizer.readState(new Xml11InputStream(in));
} else {
return externalizer.readState(in);
}
- } finally {
- in.close();
}
}
@@ -157,16 +154,13 @@ public class TaskDataStore {
private void writeState(File file, TaskDataState state) throws CoreException {
try {
- ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
- try {
+ try (ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(file)))) {
out.setMethod(ZipOutputStream.DEFLATED);
ZipEntry entry = new ZipEntry(FILE_NAME_INTERNAL);
out.putNextEntry(entry);
externalizer.writeState(out, state);
- } finally {
- out.close();
}
} catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, "Error writing task data", //$NON-NLS-1$

Back to the top