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:59:30 UTC

svn commit: r149069 - /cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java /cocoon/branches/BRANCH_2_1_X/status.xml

Author: joerg
Date: Sat Jan 29 11:59:29 2005
New Revision: 149069

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

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java?view=diff&rev=149069&p1=cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java&r1=149068&p2=cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java&r2=149069
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java	Sat Jan 29 11:59:29 2005
@@ -249,11 +249,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++;
@@ -266,9 +266,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;
@@ -340,6 +341,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/branches/BRANCH_2_1_X/status.xml
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?view=diff&rev=149069&p1=cocoon/branches/BRANCH_2_1_X/status.xml&r1=149068&p2=cocoon/branches/BRANCH_2_1_X/status.xml&r2=149069
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml	(original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml	Sat Jan 29 11:59:29 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="CZ" type="fix" fixes-bug="33178" due-to="Jean-Baptiste Quenot" due-to-email="jbq@anyware-tech.com">
      Fixing uri handling when the pass-through feature for mounting sitemaps is used.
    </action>