543815: Mylyn should use buffered output streams
Buffered output streams and replaced try-finally with try resource
Change-Id: I6c1ba2ca64c860413972d745bf44e17054d05082
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=543815
Signed-off-by: Natasha Carson <natasha.carson@tasktop.com>
diff --git a/org.eclipse.mylyn.builds.core/src/org/eclipse/mylyn/builds/core/spi/AbstractConfigurationCache.java b/org.eclipse.mylyn.builds.core/src/org/eclipse/mylyn/builds/core/spi/AbstractConfigurationCache.java
index a941ce3..f1a3280 100644
--- a/org.eclipse.mylyn.builds.core/src/org/eclipse/mylyn/builds/core/spi/AbstractConfigurationCache.java
+++ b/org.eclipse.mylyn.builds.core/src/org/eclipse/mylyn/builds/core/spi/AbstractConfigurationCache.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.mylyn.builds.core.spi;
+import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -116,10 +117,8 @@
if (cacheFile == null) {
return;
}
-
- ObjectOutputStream out = null;
- try {
- out = new ObjectOutputStream(new FileOutputStream(cacheFile));
+ try (ObjectOutputStream out = new ObjectOutputStream(
+ new BufferedOutputStream(new FileOutputStream(cacheFile)))) {
out.writeInt(configurationByUrl.size());
for (String url : configurationByUrl.keySet()) {
out.writeObject(url);
@@ -128,14 +127,6 @@
} catch (IOException e) {
StatusHandler.log(new Status(IStatus.WARNING, BuildsCorePlugin.ID_PLUGIN,
"The respository configuration cache could not be written", e)); //$NON-NLS-1$
- } finally {
- if (out != null) {
- try {
- out.close();
- } catch (IOException e) {
- // ignore
- }
- }
}
}