Closed haridsv closed 1 year ago
The below variant works fine:
public class Node {
protected Node(String tagName, Node[] children=null) {
}
}
public static Node text(String text) {
return new Node(text)
}
print(text("TEST"))
Thanks for reporting this! It looks like any use of varargs in constructors will have this issue unless you pass exactly one argument for the varargs parameter. I think it could be fixed relatively easy by changing the logic when Constructor.isVarArgs
returns true
in GroovyCallSiteSelector.isIllegalCallToSyntheticConstructor. Thankfully there is a pretty straightforward workaround: use explicit arrays or lists instead of varargs.
Thankfully there is a pretty straightforward workaround: use explicit arrays or lists instead of varargs.
Right, very simple workaround. Thankfully, I already have factory methods that take varargs so I could change the signature of the constructor without impacting any of the client code.
This was fixed incidentally as part of https://github.com/jenkinsci/groovy-sandbox/commit/520243213bcd8c81322e8e683daa8d555bb4f484 and was released in version 1.30.
I have script-security-plugin version 1.76 installed which depends on groovy-sandbox version 1.26. I started seeing the below exception in my pipeline after some recent updates and not sure exactly which update is triggering this error:
I can reproduce this using this simple pipeline script with sandbox enabled:
Full exception stack trace:
If I remove the variable number of arguments from
Node
, it works fine.We are using Jenkins 2.176.4.