You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2008/10/31 21:02:28 UTC

svn commit: r709549 - /felix/trunk/main/src/main/java/org/apache/felix/main/Main.java

Author: rickhall
Date: Fri Oct 31 13:02:28 2008
New Revision: 709549

URL: http://svn.apache.org/viewvc?rev=709549&view=rev
Log:
Fixed a possible NPE.

Modified:
    felix/trunk/main/src/main/java/org/apache/felix/main/Main.java

Modified: felix/trunk/main/src/main/java/org/apache/felix/main/Main.java
URL: http://svn.apache.org/viewvc/felix/trunk/main/src/main/java/org/apache/felix/main/Main.java?rev=709549&r1=709548&r2=709549&view=diff
==============================================================================
--- felix/trunk/main/src/main/java/org/apache/felix/main/Main.java (original)
+++ felix/trunk/main/src/main/java/org/apache/felix/main/Main.java Fri Oct 31 13:02:28 2008
@@ -57,6 +57,10 @@
      * The default name used for the configuration properties file.
     **/
     public static final String CONFIG_PROPERTIES_FILE_VALUE = "config.properties";
+    /**
+     * Name of the configuration directory.
+     */
+    public static final String CONFIG_DIRECTORY = "conf";
 
     private static Framework m_felix = null;
 
@@ -176,6 +180,13 @@
 
         // Read configuration properties.
         Properties configProps = Main.loadConfigProperties();
+        // If no configuration properties were found, then create
+        // an empty properties object.
+        if (configProps == null)
+        {
+            System.err.println("No " + CONFIG_PROPERTIES_FILE_VALUE + " found.");
+            configProps = new Properties();
+        }
 
         // Copy framework properties from the system properties.
         Main.copySystemProperties(configProps);
@@ -267,12 +278,12 @@
                 // directory of the felix.jar directory.
                 confDir = new File(
                     new File(new File(jarLocation).getAbsolutePath()).getParent(),
-                    "conf");
+                    CONFIG_DIRECTORY);
             }
             else
             {
                 // Can't figure it out so use the current directory as default.
-                confDir = new File(System.getProperty("user.dir"));
+                confDir = new File(System.getProperty("user.dir"), CONFIG_DIRECTORY);
             }
 
             try
@@ -378,12 +389,12 @@
                 // directory of the felix.jar directory.
                 confDir = new File(
                     new File(new File(jarLocation).getAbsolutePath()).getParent(),
-                    "conf");
+                    CONFIG_DIRECTORY);
             }
             else
             {
                 // Can't figure it out so use the current directory as default.
-                confDir = new File(System.getProperty("user.dir"));
+                confDir = new File(System.getProperty("user.dir"), CONFIG_DIRECTORY);
             }
 
             try