[JIRA] (JENKINS-58414) Property of object, which extends Map, couldn't be accessed

8 views
Skip to first unread message

dicomj23@gmail.com (JIRA)

unread,
Jul 9, 2019, 4:35:03 PM7/9/19
to jenkinsc...@googlegroups.com
Dicom J created an issue
 
Jenkins / Bug JENKINS-58414
Property of object, which extends Map, couldn't be accessed
Issue Type: Bug Bug
Assignee: Unassigned
Components: workflow-cps-plugin
Created: 2019-07-09 20:34
Priority: Blocker Blocker
Reporter: Dicom J

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...

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

jglick@cloudbees.com (JIRA)

unread,
Jul 10, 2019, 1:18:02 PM7/10/19
to jenkinsc...@googlegroups.com
Jesse Glick commented on Bug JENKINS-58414
 
Re: Property of object, which extends Map, couldn't be accessed

As a workaround, check if @ notation (explicit field access) helps.

dicomj23@gmail.com (JIRA)

unread,
Jul 10, 2019, 2:47:02 PM7/10/19
to jenkinsc...@googlegroups.com

dicomj23@gmail.com (JIRA)

unread,
Jul 10, 2019, 2:55:02 PM7/10/19
to jenkinsc...@googlegroups.com

dicomj23@gmail.com (JIRA)

unread,
Jul 10, 2019, 3:08:02 PM7/10/19
to jenkinsc...@googlegroups.com
Dicom J commented on Bug JENKINS-58414

Jesse Glick, @ notation works, both internally `def myFooBar() { this.@foobar }` and externally as `m.@foobar`.
Again, thanks a lot!!!

dicomj23@gmail.com (JIRA)

unread,
Jul 10, 2019, 3:09:02 PM7/10/19
to jenkinsc...@googlegroups.com
Dicom J edited a comment on Bug JENKINS-58414
[~jglick], @ notation works, both internally as `def myFooBar() \{ this.@foobar }` and externally as `m.@foobar`.
Again, thanks a lot!!!
Reply all
Reply to author
Forward
0 new messages