[JIRA] (JENKINS-59667) CpsCallableInvocation.checkMismatch with @NonCPS method calling simple groovy getter (not any step)

9 views
Skip to first unread message

dicomj23@gmail.com (JIRA)

unread,
Oct 4, 2019, 3:00:04 PM10/4/19
to jenkinsc...@googlegroups.com
Dicom J updated an issue
 
Jenkins / Bug JENKINS-59667
CpsCallableInvocation.checkMismatch with @NonCPS method calling simple groovy getter (not any step)
Change By: Dicom J
Summary: CpsCallableInvocation.checkMismatch with @NonCPS method calling simply simple groovy getter (not steps any step )
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

dicomj23@gmail.com (JIRA)

unread,
Oct 5, 2019, 7:43:02 PM10/5/19
to jenkinsc...@googlegroups.com

jglick@cloudbees.com (JIRA)

unread,
Oct 6, 2019, 8:27:02 AM10/6/19
to jenkinsc...@googlegroups.com

jglick@cloudbees.com (JIRA)

unread,
Oct 6, 2019, 8:27:02 AM10/6/19
to jenkinsc...@googlegroups.com

jglick@cloudbees.com (JIRA)

unread,
Oct 6, 2019, 8:32:03 AM10/6/19
to jenkinsc...@googlegroups.com
Jesse Glick commented on Bug JENKINS-59667
 
Re: CpsCallableInvocation.checkMismatch with @NonCPS method calling simple groovy getter (not any step)

This is not a false warning; your code is actually wrong. You would need to add @NonCPS to getFullName as well. This is just an example of the general principle that a regular method must not call a CPS-transformed method.

The more typical implementation of toString directly accesses fields, which should not have this issue, e.g.:

@NonCPS
@Override
public String toString() {
    "Test[name=$name]"
}

dicomj23@gmail.com (JIRA)

unread,
Oct 6, 2019, 9:17:02 AM10/6/19
to jenkinsc...@googlegroups.com
Dicom J commented on Bug JENKINS-59667

Jesse Glick, I figured this out and even put that into description:

> Obviously it's possible to put in @NonCPS for getFullName but that simply means that almost all methods by default must be @NonCPS, and only those that call steps must be CPS ones.

Anyways, thanks, it's good to know, I was just wondering as it was working before a new implementation of checkMismatch which doesn't complain about CPS itself but about mismatch of calls which is quite not that obvious but it gives good reference to the page describing all that.

jglick@cloudbees.com (JIRA)

unread,
Oct 6, 2019, 9:28:02 AM10/6/19
to jenkinsc...@googlegroups.com

almost all methods by default must be @NonCPS

Well, those that happen to be used from the likes of toString.

I was just wondering as it was working before…

The JENKINS-31314 work made no change to runtime behavior other than sometimes printing a warning. If your library code was triggering the warning shown in the issue description, then it was always broken, whether or not you noticed it.

Reply all
Reply to author
Forward
0 new messages