You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2005/06/17 05:12:10 UTC

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

Author: vgritsenko
Date: Thu Jun 16 20:12:09 2005
New Revision: 191064

URL: http://svn.apache.org/viewcvs?rev=191064&view=rev
Log:
Regression: cacheKey != fileName

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?rev=191064&r1=191063&r2=191064&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java Thu Jun 16 20:12:09 2005
@@ -253,14 +253,18 @@
             getLogger().debug("Selecting from: " + name + ", locale: " + locale +
                               ", directory: " + directories[index]);
         }
-        String cacheKey = getCacheKey(directories, index, name, locale);
-        XMLResourceBundle bundle = selectCached(cacheKey);
+
+        final String cacheKey = getCacheKey(directories, index, name, locale);
+        final String fileName = getFileName(directories[index], name, locale);
+
+        XMLResourceBundle bundle = selectCached(cacheKey, fileName);
         if (bundle == null) {
             synchronized (this) {
-                bundle = selectCached(cacheKey);
+                bundle = selectCached(cacheKey, fileName);
                 if (bundle == null) {
                     boolean localeAvailable = (locale != null && !locale.getLanguage().equals(""));
                     index++;
+
                     XMLResourceBundle parentBundle = null;
                     if (localeAvailable && index == directories.length) {
                         // all directories have been searched with this locale,
@@ -270,11 +274,12 @@
                         // there are directories left to search for with this locale
                         parentBundle = _select(directories, index, name, locale);
                     }
+
                     if (!isNotFoundBundle(cacheKey)) {
-                        String fileName = getFileName(directories[index - 1], name, locale);
                         bundle = _loadBundle(name, fileName, locale, parentBundle);
                         updateCache(cacheKey, bundle);
                     }
+
                     if (bundle == null) {
                         return parentBundle;
                     }
@@ -410,63 +415,56 @@
     /**
      * Selects a bundle from the cache.
      *
+     * @param cacheKey          caching key of the bundle
      * @param fileName          file name of the bundle
      * @return                  the cached bundle; null, if not found
      */
-    protected XMLResourceBundle selectCached(String fileName) {
-        XMLResourceBundle bundle = null;
-        bundle = (XMLResourceBundle) this.cache.get(fileName);
+    protected XMLResourceBundle selectCached(String cacheKey, String fileName) {
+        XMLResourceBundle bundle = (XMLResourceBundle) this.cache.get(cacheKey);
         if (bundle != null) {
             bundle.update(fileName);
-            if (getLogger().isDebugEnabled()) {
-                getLogger().debug("Returning from cache: " + fileName);
-            }
-        } else {
-            if (getLogger().isDebugEnabled()) {
-                getLogger().debug("Not found in cache: " + fileName);
-            }
         }
 
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug((bundle == null? "NOT ":"") + "In cache: " + cacheKey);
+        }
         return bundle;
     }
 
     /**
      * Checks if the bundle is in the "not-found" cache.
      *
-     * @param fileName          file name of the bundle
+     * @param cacheKey          caching key of the bundle
      * @return                  true, if the bundle wasn't found already before;
      *                          otherwise, false.
      */
-    protected boolean isNotFoundBundle(String fileName) {
-        String result = (String) this.cacheNotFound.get(fileName);
-        if (result != null) {
-            if (getLogger().isDebugEnabled()) {
-                getLogger().debug("Returning from not_found_cache: " + fileName);
-            }
-        } else {
-            if (getLogger().isDebugEnabled()) {
-                getLogger().debug("Not found in not_found_cache: " + fileName);
-            }
+    protected boolean isNotFoundBundle(String cacheKey) {
+        Object result = this.cacheNotFound.get(cacheKey);
+
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug((result == null? "NOT ":"") + "In not_found_cache: " + cacheKey);
         }
         return result != null;
     }
 
     /**
-     * Checks if the bundle is in the "not-found" cache.
+     * Stores bundle in the cache (or in the "not-found" cache,
+     * if bundle is null)
      *
-     * @param fileName          file name of the bundle
+     * @param cacheKey          caching key of the bundle
+     * @param bundle            bundle to be placed in the cache
      */
-    protected void updateCache(String fileName, XMLResourceBundle bundle) {
+    protected void updateCache(String cacheKey, XMLResourceBundle bundle) {
         if (bundle == null) {
             if (getLogger().isDebugEnabled()) {
-                getLogger().debug("Updating not_found_cache: " + fileName);
+                getLogger().debug("Updating not_found_cache: " + cacheKey);
             }
-            this.cacheNotFound.put(fileName, fileName);
+            this.cacheNotFound.put(cacheKey, cacheKey);
         } else {
             if (getLogger().isDebugEnabled()) {
-                getLogger().debug("Updating cache: " + fileName);
+                getLogger().debug("Updating cache: " + cacheKey);
             }
-            this.cache.put(fileName, bundle);
+            this.cache.put(cacheKey, bundle);
         }
     }
 }

Modified: cocoon/trunk/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/status.xml?rev=191064&r1=191063&r2=191064&view=diff
==============================================================================
--- cocoon/trunk/status.xml (original)
+++ cocoon/trunk/status.xml Thu Jun 16 20:12:09 2005
@@ -198,7 +198,7 @@
   <changes>
   <release version="@version@" date="@date@">
     <action dev="SW" type="add">
-  	   CForms block: new Tree widget, heavily inspired by Swing's JTree. Features Ajax, selection listeners,
+      CForms block: new Tree widget, heavily inspired by Swing's JTree. Features Ajax, selection listeners,
       and a lightweight data model with two implementations: a generic one, and a source-based one to build
       file explorers.
     </action>     
@@ -469,12 +469,15 @@
    </action>
   </release>
   <release version="2.1.8" date="TBD">
+    <action dev="VG" type="fix" fixes-bug="33097">
+      Fixed reloading of the i18n catalogues (regression introduced in 2.1.7).
+    </action>
     <action dev="BD" type="add" fixes-bug="35364" due-to="Askild Aaberg Olsen" due-to-email="askild@xangeli.com">
-       Forms block: sqldatabase sample added, demonstrates "zero java code" editing of SQL data
-       using the SQLTransformer.
-     </action>
+      Forms block: sqldatabase sample added, demonstrates "zero java code" editing of SQL data
+      using the SQLTransformer.
+    </action>
     <action dev="SW" type="fix" fixes-bug="35311" due-to="Jeffrey Kirby" due-to-email="jeff.kirby@wicourts.gov">
-  	   CForms block: Ensure FormHandler is always called when a field's value change.
+      CForms block: Ensure FormHandler is always called when a field's value change.
     </action>
     <action dev="RP" type="update">
       CForms block: The default HTML stylesheets have been moved into the jar packages. If they should
@@ -487,11 +490,11 @@
       has to be used. Currently this tag is only supported by the jxtemplate macro library.
     </action>     
     <action dev="SW" type="fix">
-  		Fix some multithreading issues when a background thread or cron job uses the "cocoon:" protocol, that
-  		caused the background request pipeline to be recycled by the parent thread during its execution.<br/>
-  		To use multiple threads to process a request (e.g. parallel include), background processing must use
-  		the <code>org.apache.cocoon.environment.CocoonRunnable</code> wrapper that ensures that the environment
-  		context of the main request is properly inherited by tasks running in the background.
+      Fix some multithreading issues when a background thread or cron job uses the "cocoon:" protocol, that
+      caused the background request pipeline to be recycled by the parent thread during its execution.<br/>
+      To use multiple threads to process a request (e.g. parallel include), background processing must use
+      the <code>org.apache.cocoon.environment.CocoonRunnable</code> wrapper that ensures that the environment
+      context of the main request is properly inherited by tasks running in the background.
     </action>
     <action dev="CZ" type="update">
       Mail block: Make internal protocol handling for attachments in SendMailTransformer
@@ -2303,7 +2306,7 @@
    The authentication framework now uses a configurable component to try to authenticate a user.
    This allows to drop in own authentication services or e.g. the servlet authentication mechanism.
   </action>
-  <action dev="JH" type="fix" fixes-bug="4934" due-to="Ryder Rishel" due-to-email="	ryderblue@yahoo.com">
+  <action dev="JH" type="fix" fixes-bug="4934" due-to="Ryder Rishel" due-to-email="ryderblue@yahoo.com">
    Made JSPs working in Resin that don't end on *.jsp.
   </action>
   <action dev="JH" type="update">