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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

adrianc
Author: adrianc
Date: Mon Feb  4 15:23:35 2008
New Revision: 618490

URL: http://svn.apache.org/viewvc?rev=618490&view=rev
Log:
Fixed "resource not found" exception that occurred when switching over to new XML properties file format - https://issues.apache.org/jira/browse/OFBIZ-1612.

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

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java?rev=618490&r1=618489&r2=618490&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java Mon Feb  4 15:23:35 2008
@@ -803,7 +803,7 @@
      * properties file format.
      */
     public static class UtilResourceBundle extends ResourceBundle {
-        protected static UtilCache<String, ResourceBundle> bundleCache = new UtilCache<String, ResourceBundle>("properties.UtilPropertiesBundleCache");
+        protected static UtilCache<String, UtilResourceBundle> bundleCache = new UtilCache<String, UtilResourceBundle>("properties.UtilPropertiesBundleCache");
         protected Properties properties = null;
         protected Locale locale = null;
 
@@ -817,7 +817,7 @@
 
         public static ResourceBundle getBundle(String resource, Locale locale, ClassLoader loader) throws MissingResourceException {
             String resourceName = createResourceName(resource, locale, true);
-            ResourceBundle bundle = bundleCache.get(resourceName);
+            UtilResourceBundle bundle = bundleCache.get(resourceName);
             if (bundle == null) {
                 synchronized (bundleCache) {
                     if (bundle != null) {
@@ -830,7 +830,7 @@
                         Locale candidateLocale = candidateLocales.removeLast();
                         // ResourceBundles are connected together as a singly-linked list
                         String parentName = createResourceName(resource, candidateLocale, true);
-                        ResourceBundle lookupBundle = bundleCache.get(parentName);
+                        UtilResourceBundle lookupBundle = bundleCache.get(parentName);
                         if (lookupBundle == null) {
                             Properties newProps = getProperties(resource, candidateLocale);
                             if (UtilValidate.isNotEmpty(newProps)) {
@@ -845,6 +845,12 @@
                     }
                     if (bundle == null) {
                         throw new MissingResourceException("Resource " + resource + ", locale " + locale + " not found", null, null);
+                    } else {
+                        if (!bundle.getLocale().equals(locale)) {
+                            // Create a "dummy" bundle for the requested locale
+                            // Debug.logInfo("Creating dummy bundle, size = " + bundle.properties.size(), module);
+                            bundle = new UtilResourceBundle(bundle.properties, locale, bundle);
+                        }
                     }
                     double totalTime = System.currentTimeMillis() - startTime;
                     Debug.logInfo("ResourceBundle " + resource + " (" + locale + ") created in " + totalTime + " mS", module);