struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lukasz Lenart (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (WW-4463) Support propagating ognl errors other than NoSuchPropertyException
Date Tue, 17 Feb 2015 07:03:13 GMT

     [ https://issues.apache.org/jira/browse/WW-4463?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Lukasz Lenart updated WW-4463:
------------------------------
    Fix Version/s: 2.3.22

> Support propagating ognl errors other than NoSuchPropertyException
> ------------------------------------------------------------------
>
>                 Key: WW-4463
>                 URL: https://issues.apache.org/jira/browse/WW-4463
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>    Affects Versions: 2.3.20
>            Reporter: Jasper Rosenberg
>            Priority: Minor
>              Labels: ognl
>             Fix For: 2.3.22
>
>
> So, if you have a getter on an action that does some real work (say lazy load a list
of cars from the database), and therefore might fail, it would be nice to have the option
to have that propagate the exception, rather than be interpreted as if the property was not
defined.
> The place that looks like this should be done is OgnlValueStack.setValue().  It takes
throwExceptionOnFailure, but that is all or nothing.  That ends up including XWorkExceptions
with a root issue of ognl NoSuchPropertyException.  These are frequent and not something we
care about, at least in our code base.  What I'd like to do is have some kind of parameterization
that would let me turn on error propagation for not ognl property missing error.  I did this
locally, but it had to be super hacky because OgnlValueStack.setValue() is private.  I basically
installed my own ValueStackFactory that returned a copy of OgnlValueStack with the function
changed to be like:
> {code:java}
>     /**
>      * @see com.opensymphony.xwork2.util.ValueStack#findValue(java.lang.String)
>      */
>     public Object findValue(String expr, boolean throwExceptionOnFailure) {
>         try {
>             setupExceptionOnFailure(throwExceptionOnFailure);
>             return tryFindValueWhenExpressionIsNotNull(expr);
>         } catch (OgnlException e) {
>             return handleOgnlException(expr, throwExceptionOnFailure, e);
>         } catch (XWorkException e) {
>             Throwable cause = e.getCause();
>             if (cause instanceof NoSuchPropertyException) {
>                 return handleOtherException(expr, throwExceptionOnFailure, e);
>             }
>             return handleOtherException(expr, true, e);
>         } catch (Exception e) {
>             return handleOtherException(expr, throwExceptionOnFailure, e);
>         } finally {
>             ReflectionContextState.clear(context);
>         }
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message