Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
-
Operating System: All
Platform: All
-
6290
Description
When invoking rules, if a java.lang.Error is thrown, Digester will catch it,
discard it, and throw a SAXException its place. This is unsafe and unnecessary.
In general, unless specific handling is required, errors should be allowed to
percolate up.
Example from Digester.endElement():
try {
Rule rule = (Rule) rules.get;
if (debug)
rule.body(bodyText);
} catch (Exception e) { log.error("Body event threw exception", e); throw createSAXException(e); } catch (Throwable t) { log.error("Body event threw exception", t); throw createSAXException(t.getMessage()); }
It's OK to catch Throwable in order to log its message, but it should then
immediately rethrow it. A safe version of the above would be:
try {
Rule rule = (Rule) rules.get;
if (debug) { log.debug(" Fire body() for " + rule); }
rule.body(bodyText);
} catch (Exception e)
catch (Error e)
{ log.error("Body event threw error", e); throw e; }