You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Lukasz Lenart (Issue Comment Edited) (JIRA)" <ji...@apache.org> on 2012/02/27 22:13:50 UTC
[jira] [Issue Comment Edited] (WW-3762) XWorkBasicConverter
doConvertToCollection causes ClassCastException if an item cannot be
converted
[ https://issues.apache.org/jira/browse/WW-3762?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13215481#comment-13215481 ]
Lukasz Lenart edited comment on WW-3762 at 2/27/12 9:13 PM:
------------------------------------------------------------
Can someone review the patch ?
I've extracted few dedicated convertors from XWorkBasicConvertor to allow override them by users. You can implement your own TypeConverter and register it with struts.xml as follow:
{code:xml}
<bean type="com.opensymphony.xwork2.conversion.TypeConverter" name="collection" class="com.project.MyCollectionConverter" scope="singleton"/>
{code}
If this is a good approach, I would like to extract all converters from XWorkBasicConverter to allow override them by users.
Also added Gabor's changes
was (Author: lukaszlenart):
Can someone review the patch ?
I've extracted few dedicated convertors from XWorkBasicConvertor to allow override them by users. You can implement your own TypeConverter and register it with struts.xml as follow:
{code:xml}
<bean type="com.opensymphony.xwork2.conversion.TypeConverter" name="collection" class="com.project.MyCollectionConverter" scope="singleton"/>
{code}
If this is a good approach, I would like to extract all converters from XWorkBasicConverter to all override them by users.
Also added Gabor's changes
> XWorkBasicConverter doConvertToCollection causes ClassCastException if an item cannot be converted
> --------------------------------------------------------------------------------------------------
>
> Key: WW-3762
> URL: https://issues.apache.org/jira/browse/WW-3762
> Project: Struts 2
> Issue Type: Bug
> Components: Value Stack
> Affects Versions: 2.3.1.2
> Reporter: Pelladi Gabor
> Assignee: Lukasz Lenart
> Labels: patch
> Fix For: 2.3.2
>
> Attachments: WW-3762.diff, WW-3762.patch, example.txt
>
>
> My action has a property of type List<Integer> (same for other non-string types). The action will later iterate over this property, and it gets a ClassCastException, because the list (of type List<Integer>) contains a String.
> It is because XWorkBasicConverter.doConvertToCollection() converts the input string array into an integer list. But if the input coming from the browser contains a value that cannot be converted to a string, then the string "ognl.NoConversionPossible" is put into the list. It is wrong, we should pay attention to the type of the list.
> I have attached a patch that does not put elements into the list that cannot be converted.
> I have also attached a file that contains a simple example for this bug.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira