You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by jo...@apache.org on 2005/01/29 20:58:57 UTC

svn commit: r149068 - /cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java /cocoon/trunk/status.xml

Author: joerg
Date: Sat Jan 29 11:58:56 2005
New Revision: 149068

URL: http://svn.apache.org/viewcvs?view=rev&rev=149068
Log:
Fixed caching of i18n bundles when using multiple locations. (bug 33097)
Modified:
   cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java
   cocoon/trunk/status.xml

Modified: cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java?view=diff&rev=149068&p1=cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java&r1=149067&p2=cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java&r2=149068
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java	(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java	Sat Jan 29 11:58:56 2005
@@ -248,11 +248,11 @@
             getLogger().debug("selecting from: " + name + ", locale: " + locale +
                               ", directory: " + directories[index]);
         }
-        String fileName = getFileName(directories[index], name, locale);
-        XMLResourceBundle bundle = selectCached(fileName);
+        String cacheKey = getCacheKey(directories, index, name, locale);
+        XMLResourceBundle bundle = selectCached(cacheKey);
         if (bundle == null) {
             synchronized (this) {
-                bundle = selectCached(fileName);
+                bundle = selectCached(cacheKey);
                 if (bundle == null) {
                     boolean localeAvailable = (locale != null && !locale.getLanguage().equals(""));
                     index++;
@@ -265,9 +265,10 @@
                         // there are directories left to search for with this locale
                         parentBundle = _select(directories, index, name, locale);
                     }
-                    if (!isNotFoundBundle(fileName)) {
+                    if (!isNotFoundBundle(cacheKey)) {
+                        String fileName = getFileName(directories[index - 1], name, locale);
                         bundle = _loadBundle(name, fileName, locale, parentBundle);
-                        updateCache(fileName, bundle);
+                        updateCache(cacheKey, bundle);
                     }
                     if (bundle == null) {
                         return parentBundle;
@@ -339,6 +340,15 @@
             newloc = new Locale(locale.getLanguage(), locale.getCountry(), "");
         }
         return newloc;
+    }
+
+    protected String getCacheKey(String[] directories, int index, String name, Locale locale) {
+        StringBuffer cacheKey = new StringBuffer();
+        for (; index < directories.length; index++) {
+            cacheKey.append(getFileName(directories[index], name, locale));
+            cacheKey.append(":");
+        }
+        return cacheKey.toString();
     }
 
     /**

Modified: cocoon/trunk/status.xml
Url: http://svn.apache.org/viewcvs/cocoon/trunk/status.xml?view=diff&rev=149068&p1=cocoon/trunk/status.xml&r1=149067&p2=cocoon/trunk/status.xml&r2=149068
==============================================================================
--- cocoon/trunk/status.xml	(original)
+++ cocoon/trunk/status.xml	Sat Jan 29 11:58:56 2005
@@ -202,6 +202,9 @@
 
   <changes>
  <release version="@version@" date="@date@">
+   <action dev="JH" type="fix" fixes-bug="33097">
+    Fixed caching of i18n bundles when using multiple locations.
+   </action>
    <action dev="SW" type="add">
      Add an experimental lazy loading in the service manager that dramatically speeds up Cocoon init time
      (approx 4 times faster). To use it, set JAVA_OPTIONS="-Dorg.apache.cocoon.core.LazyMode=true" prior