[JIRA] (JENKINS-50997) java.lang.UnsupportedOperationException in set map with each

0 views
Skip to first unread message

lchyqx@hotmail.com (JIRA)

unread,
Apr 25, 2018, 9:00:02 AM4/25/18
to jenkinsc...@googlegroups.com
Hubert Li created an issue
 
Jenkins / Bug JENKINS-50997
java.lang.UnsupportedOperationException in set map with each
Issue Type: Bug Bug
Assignee: Unassigned
Components: workflow-cps-plugin
Created: 2018-04-25 12:59
Environment: Jenkins ver. 2.60.1

Pipeline job plugin ver: 2.12.1
Priority: Major Major
Reporter: Hubert Li

 

Run the code in pipeline job:

Map buildStatus = ['a':'C', 'b':'N', 'c':'R', 'd':'R']
List nextBuildBranches = ['c', 'd']

buildStatus << buildStatus.subMap(nextBuildBranches).each { it.value = 'C' }

println buildStatus

I got the error message below:

 

java.lang.UnsupportedOperationException
	at java.util.AbstractMap$SimpleImmutableEntry.setValue(AbstractMap.java:797)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)

but it works in Jenkins scripts console.

 

 

 

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

svanoort@cloudbees.com (JIRA)

unread,
May 3, 2018, 11:09:02 AM5/3/18
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
May 3, 2018, 11:15:02 AM5/3/18
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
May 3, 2018, 11:23:02 AM5/3/18
to jenkinsc...@googlegroups.com
Andrew Bayer commented on Bug JENKINS-50997
 
Re: java.lang.UnsupportedOperationException in set map with each

This is due to IteratorHack in workflow-cps, which is how we're able to do iteration over map entries without serialization errors. You'll need to work around this - say, with something like:

Map buildStatus = ['a':'C', 'b':'N', 'c':'R', 'd':'R']
List nextBuildBranches = ['c', 'd']

nextBuildBranches.each { b ->
  buildStatus.put(b, "C")
}
println buildStatus
Reply all
Reply to author
Forward
0 new messages