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 00:37:31 UTC

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

Author: vgritsenko
Date: Thu Jun 16 15:37:31 2005
New Revision: 191020

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

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?rev=191020&r1=191019&r2=191020&view=diff
==============================================================================
--- 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 Thu Jun 16 15:37:31 2005
@@ -254,14 +254,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,
@@ -271,11 +275,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;
                     }
@@ -411,63 +416,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/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?rev=191020&r1=191019&r2=191020&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Thu Jun 16 15:37:31 2005
@@ -196,6 +196,9 @@
 
   <changes>
   <release version="@version@" date="@date@">
+    <action dev="VG" type="fix" fixes-bug="33097">
+      Fixed reloading of the i18n catalogues (regression introduced in 2.1.7).
+    </action>
     <action dev="UH" type="add" due-to="Johan Stuyts">
       JMS block: Connection failures can now be recovered from. The default JMSConnectionManager implementation
       detects when JMS connections are severed and schedules reconnection attempts with the cron scheduler
@@ -205,10 +208,10 @@
       updated to use this mechanism.
     </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>
-     <action dev="SW" type="fix" fixes-bug="35311" due-to="Jeffrey Kirby" due-to-email="jeff.kirby@wicourts.gov">
+      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.
     </action>
     <action dev="RP" type="update">
@@ -221,13 +224,13 @@
       don't have a natural place where the error message should appear, the <code>&lt;ft:validation-error id="[widget-id]"/&gt;</code>
       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.
-	  </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.
+    </action>
     <action dev="CZ" type="update">
       Mail block: Make internal protocol handling for attachments in SendMailTransformer
       configurable and properly release all sources.
@@ -2095,7 +2098,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">



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

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Joerg Heinicke wrote:
> On 17.06.2005 00:37, vgritsenko@apache.org wrote:
> 
>> Author: vgritsenko
>> Date: Thu Jun 16 15:37:31 2005
>> New Revision: 191020
>>
>> URL: http://svn.apache.org/viewcvs?rev=191020&view=rev
>> Log:
>> Regression: cacheKey != fileName
> 
> 
> It took some time until I found the regression I introduced. But I 
> wonder why the update method in XMLResourceBundle has a sourceURL 
> parameter at all. It makes no sense to change the source URL of a bundle 
> when reloading it, does it?

No, it does not.


> Wouldn't it be better to save the sourceURL 
> as field of the XMLResourceBundle and remove the parameter from the 
> update method?

You can even remove unused XMLResourceBundle.name and introduce 
XMLResourceBundle.sourceURI instead of it, +1 from me.

Vadim

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

Posted by Joerg Heinicke <jo...@gmx.de>.
On 17.06.2005 00:37, vgritsenko@apache.org wrote:
> Author: vgritsenko
> Date: Thu Jun 16 15:37:31 2005
> New Revision: 191020
> 
> URL: http://svn.apache.org/viewcvs?rev=191020&view=rev
> Log:
> Regression: cacheKey != fileName

It took some time until I found the regression I introduced. But I 
wonder why the update method in XMLResourceBundle has a sourceURL 
parameter at all. It makes no sense to change the source URL of a bundle 
when reloading it, does it? Wouldn't it be better to save the sourceURL 
as field of the XMLResourceBundle and remove the parameter from the 
update method?

Joerg