You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2013/04/20 17:29:45 UTC

svn commit: r1470176 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java

Author: jleroux
Date: Sat Apr 20 15:29:45 2013
New Revision: 1470176

URL: http://svn.apache.org/r1470176
Log:
Fixes "Bug in properties management." https://issues.apache.org/jira/browse/OFBIZ-5159

Yesterday, I faced a weird bug in properties management.
For a reason, a copy of a project slipped in the project itself (like if you had a copy of ofbiz root in ofbiz root).
And in this project a properties file (in a hotdeploy component) as the same name than the project (like ofbiz.properties)
Then, as properties for this file, I got all the content of the sub-dir (here would be the files in ofbiz/ofbiz) instead of the properties

This fixes it, no performance issues since properties are cached so properties file are only accessed once

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

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=1470176&r1=1470175&r2=1470176&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 20 15:29:45 2013
@@ -19,6 +19,7 @@
 package org.ofbiz.base.util;
 
 import java.io.BufferedInputStream;
+import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -302,6 +303,12 @@ public class UtilProperties implements S
 
                 if (url == null)
                     return null;
+                String fileName = url.getFile();
+                File file = new File(fileName);
+                if (file.isDirectory()) {
+                    Debug.logError(fileName + " is (also?) a directory! No properties assigned.", module);
+                    return null;
+                }
                 properties = resourceCache.putIfAbsentAndGet(cacheKey, getProperties(url));
             } catch (MissingResourceException e) {
                 Debug.logInfo(e, module);