You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2013/02/05 08:06:00 UTC

git commit: refs/heads/master - Transaction: Fix NPE while reading db.properties file

Updated Branches:
  refs/heads/master c61156e96 -> 7795cfd75


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 <bh...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/7795cfd7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/7795cfd7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/7795cfd7

Branch: refs/heads/master
Commit: 7795cfd75986874f9a947260379a761b0f3bde82
Parents: c61156e
Author: Rohit Yadav <bh...@apache.org>
Authored: Tue Feb 5 12:28:23 2013 +0530
Committer: Rohit Yadav <bh...@apache.org>
Committed: Tue Feb 5 12:35:43 2013 +0530

----------------------------------------------------------------------
 utils/src/com/cloud/utils/db/Transaction.java |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7795cfd7/utils/src/com/cloud/utils/db/Transaction.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/Transaction.java b/utils/src/com/cloud/utils/db/Transaction.java
index 73f5bb1..8bc2a04 100755
--- a/utils/src/com/cloud/utils/db/Transaction.java
+++ b/utils/src/com/cloud/utils/db/Transaction.java
@@ -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????