Skip to content

Commit 7795cfd

Browse files
committed
Transaction: Fix NPE while reading db.properties file
Handle NPE while setting up data source in Transaction - This occured as Transaction is called it would run the following which assumed db.properties file, which may not be in one's classpath; // Initialize with assumed db.properties file initDataSource("db.properties"); - So, while this would be logged in logs, this is ignored for DatabaseCreator's case. In DatabaseCreator we call initDataSource with full path anyway. Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
1 parent c61156e commit 7795cfd

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

utils/src/com/cloud/utils/db/Transaction.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,10 +1006,7 @@ public String toString() {
10061006

10071007
public static void initDataSource(String propsFileName) {
10081008
try {
1009-
File dbPropsFile = new File(propsFileName);
1010-
if (!dbPropsFile.exists()) {
1011-
dbPropsFile = PropertiesUtil.findConfigFile(propsFileName);
1012-
}
1009+
File dbPropsFile = PropertiesUtil.findConfigFile(propsFileName);
10131010
final Properties dbProps;
10141011
if (EncryptionSecretKeyChecker.useEncryption()) {
10151012
StandardPBEStringEncryptor encryptor = EncryptionSecretKeyChecker.getEncryptor();
@@ -1022,6 +1019,9 @@ public static void initDataSource(String propsFileName) {
10221019
} catch (IOException e) {
10231020
s_logger.fatal("Unable to load db properties file, pl. check the classpath and file path configuration", e);
10241021
return;
1022+
} catch (NullPointerException e) {
1023+
s_logger.fatal("Unable to load and read db properties file " + propsFileName + "Error: " + e);
1024+
return;
10251025
}
10261026

10271027
// FIXME: If params are missing...default them????

0 commit comments

Comments
 (0)