Why such a complicated exception handling?

I see several problems here:
- SourceNotFoundException is a nominal case (BTW why not using Source.exists()?) and should not log an exception - Bad formed XML files and other serious exceptions are semi-silently ignored. By semi-silently, I mean they're just logged and don't bubble up higher in the call stack, thus giving the false impression that the system works.

I will fix the 1st point (it scares my users to see all this in the logs), and would really understand the rationale for the second.

Sylvain


[EMAIL PROTECTED] wrote:
Author: vgritsenko
Date: Tue Oct 11 15:28:46 2005
New Revision: 312968

URL: http://svn.apache.org/viewcvs?rev=312968&view=rev
Log:
    <action dev="VG" type="update">
      I18n: Refactored XMLResourceBundle to use transient store instead of
      private cache. Added reload check interval parameter. Support dynamic
      additions and removals of resource bundles, without need to restart
      Cocoon.
    </action>

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/i18n/XMLResourceBundle.java
<snip/>
-        } catch (ServiceException e) {
-            throw new ProcessingException("Can't lookup source resolver", e);
+
+            // Success
+            return true;
+
         } catch (MalformedURLException e) {
-            throw new SourceNotFoundException("Invalid resource URL: " + 
this.sourceURI, e);
+            getLogger().error("Bundle <" + this.sourceURI + "> not loaded: Invalid 
URI", e);
+            newValues = Collections.EMPTY_MAP;
+
+        } catch (ResourceNotFoundException e) {
+            if (getLogger().isDebugEnabled()) {
+                getLogger().info("Bundle <" + sourceURI + "> not loaded: Source URI 
not found", e);
+            } else if (getLogger().isInfoEnabled()) {
+                getLogger().info("Bundle <" + sourceURI + "> not loaded: Source URI 
not found");
+            }
+            newValues = Collections.EMPTY_MAP;
+
+        } catch (SourceNotFoundException e) {
+            if (getLogger().isDebugEnabled()) {
+                getLogger().info("Bundle <" + sourceURI + "> not loaded: Source URI 
not found", e);
+            } else if (getLogger().isInfoEnabled()) {
+                getLogger().info("Bundle <" + sourceURI + "> not loaded: Source URI 
not found");
+            }
+            newValues = Collections.EMPTY_MAP;
+
+        } catch (SAXException e) {
+            getLogger().error("Bundle <" + sourceURI + "> not loaded: Invalid 
XML", e);
+            // Keep existing loaded values
+            newValues = this.values;
+
+        } catch (Exception e) {
+            getLogger().error("Bundle <" + sourceURI + "> not loaded: 
Exception", e);
+            // Keep existing loaded values
+            newValues = this.values;
+
         } finally {
-            if (source != null) {
-                resolver.release(source);
+            if (newSource != null) {
+                resolver.release(newSource);
             }
-            this.manager.release(resolver);
         }
-    }

--
Sylvain Wallez                        Anyware Technologies
http://people.apache.org/~sylvain     http://www.anyware-tech.com
Apache Software Foundation Member     Research & Technology Director

Reply via email to