summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcedricbosdo <cedricbosdo>2007-12-07 07:32:31 +0000
committercedricbosdo <cedricbosdo>2007-12-07 07:32:31 +0000
commita9436796dc712e757daaa992e35625462aaf0304 (patch)
tree7e03a934b96ba415b794943932e35d03f0f4a8cc
parent92968fa3d7e9ae27fd791e664c5db4ae1e24a374 (diff)
Some properties files streams where not closed after use. Fixed
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/internal/helpers/PropertiesManager.java21
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/internal/helpers/UnoidlProjectHelper.java10
-rwxr-xr-xcore/source/org/openoffice/ide/eclipse/core/internal/model/SDK.java10
-rwxr-xr-xcore/source/org/openoffice/ide/eclipse/core/internal/model/UnoidlProject.java30
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/model/PackagePropertiesModel.java13
5 files changed, 46 insertions, 38 deletions
diff --git a/core/source/org/openoffice/ide/eclipse/core/internal/helpers/PropertiesManager.java b/core/source/org/openoffice/ide/eclipse/core/internal/helpers/PropertiesManager.java
index efac6c8..7236200 100644
--- a/core/source/org/openoffice/ide/eclipse/core/internal/helpers/PropertiesManager.java
+++ b/core/source/org/openoffice/ide/eclipse/core/internal/helpers/PropertiesManager.java
@@ -2,9 +2,9 @@
*
* $RCSfile: PropertiesManager.java,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: cedricbosdo $ $Date: 2007/11/25 20:32:31 $
+ * last change: $Author: cedricbosdo $ $Date: 2007/12/07 07:32:31 $
*
* The Contents of this file are made available subject to the terms of
* the GNU Lesser General Public License Version 2.1
@@ -183,12 +183,7 @@ public class PropertiesManager {
} catch (IOException e) {
PluginLogger.error(e.getLocalizedMessage(), e);
} finally {
- try {
- if (out != null) {
- out.close();
- }
- } catch (IOException e) {
- }
+ try { out.close(); } catch (Exception e) { }
}
}
@@ -313,12 +308,7 @@ public class PropertiesManager {
} catch (IOException e) {
PluginLogger.error(e.getLocalizedMessage(), e);
} finally {
- try {
- if (out != null) {
- out.close();
- }
- } catch (IOException e) {
- }
+ try { out.close(); } catch (Exception e) { }
}
}
@@ -345,8 +335,7 @@ public class PropertiesManager {
try {
ooosProperties.load(in);
} finally {
- try { in.close(); } catch (IOException e) {
- }
+ try { in.close(); } catch (IOException e) { }
}
return ooosProperties;
diff --git a/core/source/org/openoffice/ide/eclipse/core/internal/helpers/UnoidlProjectHelper.java b/core/source/org/openoffice/ide/eclipse/core/internal/helpers/UnoidlProjectHelper.java
index e802659..43e18ad 100644
--- a/core/source/org/openoffice/ide/eclipse/core/internal/helpers/UnoidlProjectHelper.java
+++ b/core/source/org/openoffice/ide/eclipse/core/internal/helpers/UnoidlProjectHelper.java
@@ -2,9 +2,9 @@
*
* $RCSfile: UnoidlProjectHelper.java,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: cedricbosdo $ $Date: 2007/11/25 20:32:31 $
+ * last change: $Author: cedricbosdo $ $Date: 2007/12/07 07:32:31 $
*
* The Contents of this file are made available subject to the terms of
* the GNU Lesser General Public License Version 2.1
@@ -45,6 +45,7 @@ package org.openoffice.ide.eclipse.core.internal.helpers;
import java.io.File;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.util.Properties;
import org.eclipse.core.resources.IFolder;
@@ -111,11 +112,14 @@ public class UnoidlProjectHelper {
properties.setProperty(UnoidlProject.IDL_DIR, IDL_BASIS);
properties.setProperty(UnoidlProject.BUILD_DIR, BUILD_BASIS);
+ FileOutputStream out = null;
try {
- FileOutputStream out = new FileOutputStream(pConfigFile);
+ out = new FileOutputStream(pConfigFile);
properties.store(out, "UNO project configuration file");
} catch (Exception e) {
PluginLogger.warning("Can't create default uno configuration file", e);
+ } finally {
+ try { out.close(); } catch (IOException e) { }
}
}
diff --git a/core/source/org/openoffice/ide/eclipse/core/internal/model/SDK.java b/core/source/org/openoffice/ide/eclipse/core/internal/model/SDK.java
index 279ad01..3c0f1e1 100755
--- a/core/source/org/openoffice/ide/eclipse/core/internal/model/SDK.java
+++ b/core/source/org/openoffice/ide/eclipse/core/internal/model/SDK.java
@@ -2,9 +2,9 @@
*
* $RCSfile: SDK.java,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: cedricbosdo $ $Date: 2007/11/25 20:32:26 $
+ * last change: $Author: cedricbosdo $ $Date: 2007/12/07 07:32:31 $
*
* The Contents of this file are made available subject to the terms of
* the GNU Lesser General Public License Version 2.1
@@ -485,8 +485,10 @@ public class SDK implements ISdk, ITableElement {
File dkFile = new File(pSettingsFile, F_DK_CONFIG);
Properties dkProperties = new Properties();
+ FileInputStream in = null;
try {
- dkProperties.load(new FileInputStream(dkFile));
+ in = new FileInputStream(dkFile);
+ dkProperties.load(in);
// Checks if the name and buildid properties are set
if (dkProperties.containsKey(K_SDK_BUILDID)) {
@@ -510,6 +512,8 @@ public class SDK implements ISdk, ITableElement {
Messages.getString("SDK.NoReadableFileError") +
"settings/" + F_DK_CONFIG, //$NON-NLS-1$ //$NON-NLS-2$
InvalidConfigException.INVALID_SDK_HOME);
+ } finally {
+ try { in.close(); } catch (Exception e) { }
}
} else {
diff --git a/core/source/org/openoffice/ide/eclipse/core/internal/model/UnoidlProject.java b/core/source/org/openoffice/ide/eclipse/core/internal/model/UnoidlProject.java
index 4d729d0..0d9ab5e 100755
--- a/core/source/org/openoffice/ide/eclipse/core/internal/model/UnoidlProject.java
+++ b/core/source/org/openoffice/ide/eclipse/core/internal/model/UnoidlProject.java
@@ -2,9 +2,9 @@
*
* $RCSfile: UnoidlProject.java,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: cedricbosdo $ $Date: 2007/11/25 20:32:26 $
+ * last change: $Author: cedricbosdo $ $Date: 2007/12/07 07:32:31 $
*
* The Contents of this file are made available subject to the terms of
* the GNU Lesser General Public License Version 2.1
@@ -46,6 +46,7 @@ package org.openoffice.ide.eclipse.core.internal.model;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.text.MessageFormat;
import java.util.Properties;
@@ -509,17 +510,20 @@ public class UnoidlProject implements IUnoidlProject, IProjectNature {
File configFile = getConfigFile();
String property = null;
+ FileInputStream in = null;
try {
// Create a default configuration file if needed
if (!configFile.exists()) {
UnoidlProjectHelper.createDefaultConfig(configFile);
}
- FileInputStream in = new FileInputStream(configFile);
+ in = new FileInputStream(configFile);
properties.load(in);
property = properties.getProperty(pPropertyName);
} catch (Exception e) {
PluginLogger.warning("Unreadable uno project configuration file " + CONFIG_FILE, e);
+ } finally {
+ try { in.close(); } catch (IOException e) { }
}
return property;
@@ -535,18 +539,20 @@ public class UnoidlProject implements IUnoidlProject, IProjectNature {
Properties properties = new Properties();
File configFile = getConfigFile();
+ FileInputStream in = null;
+ FileOutputStream out = null;
try {
// Create a default configuration file if needed
if (!configFile.exists()) {
UnoidlProjectHelper.createDefaultConfig(configFile);
}
- FileInputStream in = new FileInputStream(configFile);
+ in = new FileInputStream(configFile);
properties.load(in);
properties.setProperty(pName, pValue);
- FileOutputStream out = new FileOutputStream(configFile);
+ out = new FileOutputStream(configFile);
properties.store(out, "UNO project configuration file");
// Refresh the configuration file
@@ -556,6 +562,9 @@ public class UnoidlProject implements IUnoidlProject, IProjectNature {
String message = MessageFormat.format("Error during project property change ({0}, {1})",
pName, pValue);
PluginLogger.warning(message, e);
+ } finally {
+ try { in.close(); } catch (IOException e) { }
+ try { out.close(); } catch (IOException e) { }
}
}
@@ -572,8 +581,10 @@ public class UnoidlProject implements IUnoidlProject, IProjectNature {
UnoidlProjectHelper.createDefaultConfig(configFile);
}
+ FileInputStream in = null;
+ FileOutputStream out = null;
try {
- FileInputStream in = new FileInputStream(configFile);
+ in = new FileInputStream(configFile);
properties.load(in);
properties.setProperty(LANGUAGE, LanguagesHelper.getNameFromLanguage(mLanguage));
@@ -584,16 +595,17 @@ public class UnoidlProject implements IUnoidlProject, IProjectNature {
properties.setProperty(COMPANY_PREFIX, mCompanyPrefix);
properties.setProperty(OUTPUT_EXT, mOutputExtension);
- FileOutputStream out = new FileOutputStream(configFile);
+ out = new FileOutputStream(configFile);
properties.store(out, "UNO project configuration file");
- out.close();
-
// Refresh the configuration file
getFile(CONFIG_FILE).refreshLocal(IResource.DEPTH_ZERO, null);
} catch (Exception e) {
PluginLogger.warning("Error saving all the project properties", e);
+ } finally {
+ try { in.close(); } catch (IOException e) { }
+ try { out.close(); } catch (IOException e) { }
}
}
diff --git a/core/source/org/openoffice/ide/eclipse/core/model/PackagePropertiesModel.java b/core/source/org/openoffice/ide/eclipse/core/model/PackagePropertiesModel.java
index 9b9672c..43ba8cd 100644
--- a/core/source/org/openoffice/ide/eclipse/core/model/PackagePropertiesModel.java
+++ b/core/source/org/openoffice/ide/eclipse/core/model/PackagePropertiesModel.java
@@ -2,9 +2,9 @@
*
* $RCSfile: PackagePropertiesModel.java,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: cedricbosdo $ $Date: 2007/11/25 20:32:30 $
+ * last change: $Author: cedricbosdo $ $Date: 2007/12/07 07:32:32 $
*
* The Contents of this file are made available subject to the terms of
* the GNU Lesser General Public License Version 2.1
@@ -108,12 +108,10 @@ public class PackagePropertiesModel {
try {
mProperties.load(is);
} catch (IOException e) {
- try {
- is.close();
- } catch (IOException ex) {
- }
PluginLogger.warning(
Messages.getString("PackagePropertiesModel.FileReadException") + pFile.getLocation()); //$NON-NLS-1$
+ } finally {
+ try { is.close(); } catch (Exception e) { }
}
}
@@ -192,8 +190,9 @@ public class PackagePropertiesModel {
Messages.getString("PackagePropertiesModel.Comment")); //$NON-NLS-1$
firePackageSaved();
} catch (IOException e) {
- os.close();
throw e;
+ } finally {
+ try { os.close(); } catch (Exception e) { }
}
}