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] [Commented] (WW-4138) OgnlTextParser contains a NPE when the expression is passed in as null
Date Mon, 15 Jul 2013 06:54:49 GMT

    [ https://issues.apache.org/jira/browse/WW-4138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13708271#comment-13708271
] 

Lukasz Lenart commented on WW-4138:
-----------------------------------

Have you tried to use that implementation with your current applications? You can use your
own implementation of {{TextParser}} via extension point:

http://struts.apache.org/development/2.x/docs/plugins.html#Plugins-ExtensionPoints

You must just define bean and constant like below:
{code:xml}
<bean type="com.opensymphony.xwork2.util.TextParser" name="myParser" class="com.comapny.MyTextParser"
scope="singleton"/>
<constant name="struts.expression.parser" value="myParser" />
{code}

I would like to know if that works?
                
> OgnlTextParser contains a NPE when the expression is passed in as null
> ----------------------------------------------------------------------
>
>                 Key: WW-4138
>                 URL: https://issues.apache.org/jira/browse/WW-4138
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.3.15
>            Reporter: David Greene
>             Fix For: 2.3.16
>
>
> Unfortunately, I haven't figured out the exact cause of the issue; however, the fix provided
brings our system back to how it used to work.
> When expression is passed in a null, a NPE is thrown @:
> int start = expression.indexOf(lookupChars, pos);
> {code}
>         Object result = expression;
>         int pos = 0;
>         for (char open : openChars) {
>             int loopCount = 1;
>             //this creates an implicit StringBuffer and shouldn't be used in the inner
loop
>             final String lookupChars = open + "{";
>             while (true) {
>                 int start = expression.indexOf(lookupChars, pos);
>                 if (start == -1) {
>                     loopCount++;
>                     start = expression.indexOf(lookupChars);
>                 }
> {code}
> Here is the fix I'm using in a locally built class file:
> {code}
>         Object result = expression = (expression == null) ? "" : expression;
>         int pos = 0;
>         for (char open : openChars) {
>             int loopCount = 1;
>             //this creates an implicit StringBuffer and shouldn't be used in the inner
loop
>             final String lookupChars = open + "{";
>             while (true) {
>                 int start = expression.indexOf(lookupChars, pos);
>                 if (start == -1) {
>                     loopCount++;
>                     start = expression.indexOf(lookupChars);
>                 }
> {code}
> I can see about 10 different ways to 'fix' the issue, but this keeps the change to a
single line since I don't entirely understand the workflow of what's going on.
> FYI, it seems to have something to do with validate="true" on the form and when there
are fields to validate which have nested getters, aka:
> <@s.hidden key="myFakePatternHolder.pattern.id"/>

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message