Peter SEVERIN created VELOCITY-998:
--------------------------------------
Summary: Exception swallowed when context cartrige with no method
exception handler
Key: VELOCITY-998
URL: https://issues.apache.org/jira/browse/VELOCITY-998
Project: Velocity
Issue Type: Bug
Components: Engine
Affects Versions: 2.4.1
Reporter: Peter SEVERIN
The EventHandlerUtil.methodException method can swallow the exception if there
is a context EventCartrige with no method exception handler attached. The
following code calls EventCartrige#methodException method:
{{ EventCartridge contextCartridge = context.getEventCartridge();}}
{{ if (contextCartridge != null)}}
{{ {}}
{{ contextCartridge.setRuntimeServices(rsvc);}}
{{ return contextCartridge.methodException(context, claz,
method, e, info);}}
{{ }}}
Which looks like this:
{{ if (methodExceptionHandler != null)}}
{{ {}}
{{ return methodExceptionHandler.methodException(context, claz,
method, e, info);}}
{{ }}}
{{ return null;}}
When no method exception handler is set the method returns null and the
exception is lost. This should not be the case as the behavior is different
when there is no context EventCartrige.
The fix should looks like this:
{{ EventCartridge contextCartridge = context.getEventCartridge();}}
{{ if (contextCartridge != null{color:#de350b} &&
contextCartridge.hasMethodExceptionEventHandler(){color})}}
{{ {}}
{{ contextCartridge.setRuntimeServices(rsvc);}}
{{ return contextCartridge.methodException(context, claz,
method, e, info);}}
{{ }}}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]