Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-50997

java.lang.UnsupportedOperationException in set map with each

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • workflow-cps-plugin
    • None
    • Jenkins ver. 2.60.1

      Pipeline job plugin ver: 2.12.1

       

      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.

       

       

       

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

          Hubert Li created issue -
          Andrew Bayer made changes -
          Priority Original: Major [ 3 ] New: Minor [ 4 ]

            Unassigned Unassigned
            hubertli Hubert Li
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: