struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Lindal (JIRA)" <>
Subject [jira] Assigned: (WW-3397) IncludeProperties within Json plugin are not handled properly with patterns including arrays
Date Sat, 05 Feb 2011 04:50:30 GMT


John Lindal reassigned WW-3397:

    Assignee: John Lindal

> IncludeProperties within Json plugin are not handled properly with patterns including
> --------------------------------------------------------------------------------------------
>                 Key: WW-3397
>                 URL:
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 2.1.8
>            Reporter: Paolo Lutterotti
>            Assignee: John Lindal
> In order to repeat the error (on version struts2-json-plugin-2.1.8 ) it's enough to use
a regexp pattern like this(in general the use of array \[\d+\] should be not at the first
level, but deeper):
> <param name="includeProperties">							
> 					operatorsgrid\.items\[\d+\]\.name
> </param>
> This pattern aims to extract a name property given this structure:
> 1)The Action has a getter:
> OperatorsDTO getOperatorsgrid(){};
> 2)OperatorsDTO is defined as:
> class OperatorsDTO{
>    public List<Operators> getItems(){}
> }
> 3)Each Operator bean has (among others) a getName() method returning a String
> With this configuration, the JSON created will be empty (just {"operatorsgrid":{}} ).
> The problem has to be found in the method setIncludeProperties() of org.apache.struts2.json.JSONResult
> Given the above regexp, this method produces this list of patterns:
> [operatorsgrid, opera, operatorsgrid\.items\[\d+\], operatorsgrid\.items\[\d+\]\.name]
> Clearly there is the lack of one fundamental item: operatorsgrid\.items . Without this,
the property items won't be explored. moreover there is another item "opera" which apparently
is meaningless.
> The error is at line 160:
>   this.includeProperties.add(Pattern.compile(patternExpr.substring(0, patternPiece
>                                     .lastIndexOf("\\["))));
> patternPiece is already a substring of  patternExpr (line 151) so if this lines aims
to add a new pattern which just excludes the las \[\d+\], it should be changed to:
> this.includeProperties.add(Pattern.compile(patternExpr.substring(0, patternExpr
>                                     .lastIndexOf("\\["))));
> Given this, the new pattern set becomes:
> [operatorsgrid, operatorsgrid\.items, operatorsgrid\.items\[\d+\], operatorsgrid\.items\[\d+\]\.name]
> now the "opera" is vanished while we have operatorsgrid\.items which allows to dig into
Operators bean.

This message is automatically generated by JIRA.
For more information on JIRA, see:


View raw message