There are 3 updates.
 
 
XWiki Commons / cid:jira-generated-image-avatar-08179550-a621-44f2-ae1c-67d57ef4d80d XCOMMONS-3520 In Progress

Cannot add an array to a collection using addAll in Velocity

 
View issue   ยท   Add comment
 

3 updates

 
cid:jira-generated-image-avatar-e5f975ff-922a-4359-81ec-98d674a44429 Changes by Thomas Mortagne on 08/Jan/26 14:17
 
Description: *Steps to reproduce:*

Execute the following Velocity code in XWiki:
{noformat}
#set ($
mySet myList = $collectiontool.getOrderedSet( [] ) )
#set ($myString = 'a few words')
#set ($myArray = $
stringtool myString .split( $myString, ' '))
#set ($discard = $
mySet myList .addAll($myArray))
$
mySet myList
{noformat}

*Expected result:*

{noformat}
[a, few, words]
{noformat}

*Actual result:*

{noformat}
[]
{noformat}

The root cause seems to be that the conversion of the argument fails because during the conversion the type variable isn't resolved.

See XCOMMONS-129 for a workaround how to convert the array to a list first.
Assignee: Thomas Mortagne
Status: Open In Progress