Author: adrianc
Date: Sat Apr 18 08:30:03 2015
New Revision: 1674453

URL: http://svn.apache.org/r1674453
Log:
A small change to the behavior of the UtilProperties.createProperties() method: 
if the file is not found, return null instead of throwing an exception.

https://issues.apache.org/jira/browse/OFBIZ-6261

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/Debug.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/Debug.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/Debug.java?rev=1674453&r1=1674452&r2=1674453&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/Debug.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/Debug.java Sat Apr 18 
08:30:03 2015
@@ -66,8 +66,12 @@ public final class Debug {
 
         // initialize levelOnCache
         Properties properties = 
UtilProperties.createProperties("debug.properties");
-        for (int i = 0; i < levelOnCache.length; i++) {
-            levelOnCache[i] = (i == Debug.ALWAYS || 
"true".equalsIgnoreCase(properties.getProperty(levelProps[i])));
+        if (properties != null) {
+            for (int i = 0; i < levelOnCache.length; i++) {
+                levelOnCache[i] = (i == Debug.ALWAYS || 
"true".equalsIgnoreCase(properties.getProperty(levelProps[i])));
+            }
+        } else {
+            throw new IllegalStateException("debug.properties file not found");
         }
     }
 

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java?rev=1674453&r1=1674452&r2=1674453&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java 
(original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java Sat 
Apr 18 08:30:03 2015
@@ -287,9 +287,10 @@ public class UtilProperties implements S
      * properties files before OFBiz has been fully initialized.</p>
      * 
      * @param fileName The full name of the properties file ("foo.properties")
-     * @return A new <code>Properties</code> instance created from 
<code>fileName</code>
+     * @return A new <code>Properties</code> instance created from 
<code>fileName</code>, or
+     * <code>null</code> if the file was not found
      * @throws IllegalArgumentException if <code>fileName</code> is empty
-     * @throws IllegalStateException if there were any problems reading the 
file
+     * @throws IllegalStateException if there was a problem reading the file
      */
     public static Properties createProperties(String fileName) {
         Assert.notEmpty("fileName", fileName);
@@ -297,14 +298,14 @@ public class UtilProperties implements S
         try {
             URL url = 
Thread.currentThread().getContextClassLoader().getResource(fileName);
             if (url == null) {
-                throw new IllegalStateException(fileName + " not found");
+                return null;
             }
             inStream = url.openStream();
             Properties properties = new Properties();
             properties.load(inStream);
             return properties;
         } catch (Exception e) {
-            throw new IllegalStateException("Exception thrown while reading 
debug.properties: " + e);
+            throw new IllegalStateException("Exception thrown while reading " 
+ fileName + ": " + e);
         } finally {
             if (inStream != null) {
                 try {


Reply via email to