InputStream use fix

Closes the FileInputStream opened at configuration in
- ClusterManagerImpl
- ClusterServiceServletAdapter
- TransactionLegacy
- AsyncJobManagerImpl
- DBEncryptionUtil
- EncryptionSecretKeyChecker

Signed-off-by: Laszlo Hornyak <laszlo.hornyak@gmail.com>
This commit is contained in:
Laszlo Hornyak 2013-10-25 20:38:36 +02:00
parent c17831532e
commit dbaa818d1e
6 changed files with 6 additions and 9 deletions

View File

@ -17,7 +17,6 @@
package com.cloud.cluster; package com.cloud.cluster;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.net.ConnectException; import java.net.ConnectException;
@ -1033,7 +1032,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C
File dbPropsFile = PropertiesUtil.findConfigFile("db.properties"); File dbPropsFile = PropertiesUtil.findConfigFile("db.properties");
Properties dbProps = new Properties(); Properties dbProps = new Properties();
try { try {
dbProps.load(new FileInputStream(dbPropsFile)); PropertiesUtil.loadFromFile(dbProps, dbPropsFile);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
throw new ConfigurationException("Unable to find db.properties"); throw new ConfigurationException("Unable to find db.properties");
} catch (IOException e) { } catch (IOException e) {

View File

@ -17,7 +17,6 @@
package com.cloud.cluster; package com.cloud.cluster;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.rmi.RemoteException; import java.rmi.RemoteException;
@ -126,7 +125,7 @@ public class ClusterServiceServletAdapter extends AdapterBase implements Cluster
File dbPropsFile = PropertiesUtil.findConfigFile("db.properties"); File dbPropsFile = PropertiesUtil.findConfigFile("db.properties");
Properties dbProps = new Properties(); Properties dbProps = new Properties();
try { try {
dbProps.load(new FileInputStream(dbPropsFile)); PropertiesUtil.loadFromFile(dbProps, dbPropsFile);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
throw new ConfigurationException("Unable to find db.properties"); throw new ConfigurationException("Unable to find db.properties");
} catch (IOException e) { } catch (IOException e) {

View File

@ -1039,6 +1039,7 @@ public class TransactionLegacy {
dbProps = new Properties(); dbProps = new Properties();
} }
try { try {
PropertiesUtil.loadFromFile(dbProps, dbPropsFile);
dbProps.load(new FileInputStream(dbPropsFile)); dbProps.load(new FileInputStream(dbPropsFile));
} catch (IOException e) { } catch (IOException e) {
s_logger.fatal("Unable to load db properties file, pl. check the classpath and file path configuration", e); s_logger.fatal("Unable to load db properties file, pl. check the classpath and file path configuration", e);

View File

@ -18,7 +18,6 @@
package org.apache.cloudstack.framework.jobs.impl; package org.apache.cloudstack.framework.jobs.impl;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
@ -868,7 +867,7 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
try { try {
final File dbPropsFile = PropertiesUtil.findConfigFile("db.properties"); final File dbPropsFile = PropertiesUtil.findConfigFile("db.properties");
final Properties dbProps = new Properties(); final Properties dbProps = new Properties();
dbProps.load(new FileInputStream(dbPropsFile)); PropertiesUtil.loadFromFile(dbProps, dbPropsFile);
final int cloudMaxActive = Integer.parseInt(dbProps.getProperty("db.cloud.maxActive")); final int cloudMaxActive = Integer.parseInt(dbProps.getProperty("db.cloud.maxActive"));

View File

@ -78,7 +78,7 @@ public class DBEncryptionUtil {
StandardPBEStringEncryptor encryptor = EncryptionSecretKeyChecker.getEncryptor(); StandardPBEStringEncryptor encryptor = EncryptionSecretKeyChecker.getEncryptor();
dbProps = new EncryptableProperties(encryptor); dbProps = new EncryptableProperties(encryptor);
try { try {
dbProps.load(new FileInputStream(dbPropsFile)); PropertiesUtil.loadFromFile(dbProps, dbPropsFile);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
throw new CloudRuntimeException("db.properties file not found while reading DB secret key", e); throw new CloudRuntimeException("db.properties file not found while reading DB secret key", e);
} catch (IOException e) { } catch (IOException e) {

View File

@ -18,7 +18,6 @@ package com.cloud.utils.crypt;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
@ -62,7 +61,7 @@ public class EncryptionSecretKeyChecker extends AdapterBase implements SystemInt
final File dbPropsFile = PropertiesUtil.findConfigFile("db.properties"); final File dbPropsFile = PropertiesUtil.findConfigFile("db.properties");
final Properties dbProps = new Properties(); final Properties dbProps = new Properties();
try { try {
dbProps.load(new FileInputStream(dbPropsFile)); PropertiesUtil.loadFromFile(dbProps, dbPropsFile);
final String encryptionType = dbProps.getProperty("db.cloud.encryption.type"); final String encryptionType = dbProps.getProperty("db.cloud.encryption.type");