[
https://issues.apache.org/jira/browse/WW-3397?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
John Lindal resolved WW-3397.
-----------------------------
Resolution: Duplicate
Fix Version/s: 2.2.2
Duplicate of WW-3509
> IncludeProperties within Json plugin are not handled properly with patterns
> including arrays
> --------------------------------------------------------------------------------------------
>
> Key: WW-3397
> URL: https://issues.apache.org/jira/browse/WW-3397
> Project: Struts 2
> Issue Type: Bug
> Components: Other
> Affects Versions: 2.1.8
> Reporter: Paolo Lutterotti
> Assignee: John Lindal
> Fix For: 2.2.2
>
>
> 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 class
> 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: http://www.atlassian.com/software/jira