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>
This commit is contained in:
Rohit Yadav 2013-02-05 12:28:23 +05:30
parent c61156e965
commit 7795cfd759
1 changed files with 4 additions and 4 deletions

View File

@ -1006,10 +1006,7 @@ public class Transaction {
public static void initDataSource(String propsFileName) {
try {
File dbPropsFile = new File(propsFileName);
if (!dbPropsFile.exists()) {
dbPropsFile = PropertiesUtil.findConfigFile(propsFileName);
}
File dbPropsFile = PropertiesUtil.findConfigFile(propsFileName);
final Properties dbProps;
if (EncryptionSecretKeyChecker.useEncryption()) {
StandardPBEStringEncryptor encryptor = EncryptionSecretKeyChecker.getEncryptor();
@ -1022,6 +1019,9 @@ public class Transaction {
} catch (IOException e) {
s_logger.fatal("Unable to load db properties file, pl. check the classpath and file path configuration", e);
return;
} catch (NullPointerException e) {
s_logger.fatal("Unable to load and read db properties file " + propsFileName + "Error: " + e);
return;
}
// FIXME: If params are missing...default them????