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

ArrayList.empty works differently in a Pipeline than in Groovy

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • pipeline
    • None

      In a Pipeline ArrayList.empty is applied to each element of the list and returns another ArrayList.

      In a normal console Groovy script ArrayList.empty returns a boolean value which answers, whether the list empty or not.

      What is the reason for this difference? Is it expected or a bug? I always thought that when I call Java class method in the Pipeline script it should work like in Java. From this point of view it seems as a bug.

       

      Example:

      def listA = []
      def listB = [ "1", "2", "3" ]
      println('listA.empty=' + listA.empty)
      println('listB.empty=' + listB.empty) 

      Groovy command line output:

      listA.empty=true
      listB.empty=false

      Pipeline output:

      listA.empty=[]
      listB.empty=[false, false, false]

            Unassigned Unassigned
            alexander_samoylov Alexander Samoylov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: