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

Property of object, which extends Map, couldn't be accessed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Blocker Blocker
    • workflow-cps-plugin
    • None

      Code (also used within library):

      class MyMap extends java.util.LinkedHashMap {
          public final String foobar
      
          MyMap(Map map) {
              super(map)
              this.foobar = 'foobar'
          }
      
          def myFooBar() {
              return this.foobar
          }
      }
      
      node {
          def m = new MyMap([foo: 'bar', bar: 'foo'])
          print "bar=${m.bar}"
          print "foo=${m.foo}"
          print "foobar=${m.foobar}"
          print "foobar=${m.myFooBar()}"
      } 

      Result:

      [Pipeline] node
      Running on Jenkins in /build/workspace
      [Pipeline] {
      [Pipeline] echo
      bar=foo
      [Pipeline] echo
      foo=bar
      [Pipeline] echo
      foobar=null
      [Pipeline] echo
      foobar=null
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      Finished: SUCCESS 

       

      Expected: 'foobar' value printed

      Conceptually and most likely overloaded getProperty(name) method has a bug...

            Unassigned Unassigned
            dicomj23 Dicom J
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: