This issue has been created
There is 1 update.
 
 
XWiki Commons / cid:jira-generated-image-avatar-397c50c3-9e11-4335-b2f9-d7c30608d310 XCOMMONS-3520 Open

Cannot add an array to a collection using addAll in Velocity

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-64bf8b11-9798-4862-8c70-39e9df0fb2f2 Michael Hamann created this issue on 19/Dec/25 15:58
 
Summary: Cannot add an array to a collection using addAll in Velocity
Issue Type: cid:jira-generated-image-avatar-397c50c3-9e11-4335-b2f9-d7c30608d310 Bug
Affects Versions: 16.10.0
Assignee: Unassigned
Components: Velocity
Created: 19/Dec/25 15:58
Priority: cid:jira-generated-image-static-major-c88a45ac-a7f9-4037-8c5c-e14ee00b4f90 Major
Reporter: Michael Hamann
Description:

Steps to reproduce:

Execute the following Velocity code in XWiki:

#set ($mySet = $collectiontool.getOrderedSet())
#set ($myString = 'a few words')
#set ($myArray = $stringtool.split($myString, ' '))
#set ($discard = $mySet.addAll($myArray))
$mySet

Expected result:

[a, few, words]

Actual result:

[]

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

 
 

1 update

 
cid:jira-generated-image-avatar-64bf8b11-9798-4862-8c70-39e9df0fb2f2 Changes by Michael Hamann on 19/Dec/25 16:07
 
Description: *Steps to reproduce:*

Execute the following Velocity code in XWiki:
{noformat}
#set ($mySet = $collectiontool.getOrderedSet())
#set ($myString = 'a few words')
#set ($myArray = $stringtool.split($myString, ' '))
#set ($discard = $mySet.addAll($myArray))
$mySet
{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.