@@ -77,16 +77,24 @@ public class ScriptlerBuilder extends Builder implements Serializable {
7777 /**
7878 * @deprecated as of 3.5; use {@link #ScriptlerBuilder(String, String, boolean, List)}
7979 */
80- @ Deprecated
81- public ScriptlerBuilder (String builderId , String scriptId , boolean propagateParams , Parameter [] parameters ) {
82- this (builderId , scriptId , propagateParams , Arrays .asList (Objects .requireNonNull (parameters )));
80+ @ Deprecated (since = "3.5" )
81+ public ScriptlerBuilder (
82+ @ CheckForNull String builderId ,
83+ @ CheckForNull String scriptId ,
84+ boolean propagateParams ,
85+ @ CheckForNull Parameter [] parameters ) {
86+ this (builderId , scriptId , propagateParams , parameters == null ? List .of () : List .of (parameters ));
8387 }
8488
8589 @ DataBoundConstructor
86- public ScriptlerBuilder (String builderId , String scriptId , boolean propagateParams , @ NonNull List <Parameter > parameters ) {
90+ public ScriptlerBuilder (
91+ @ CheckForNull String builderId ,
92+ @ CheckForNull String scriptId ,
93+ boolean propagateParams ,
94+ @ CheckForNull List <Parameter > parameters ) {
8795 this .builderId = builderId ;
8896 this .scriptId = scriptId ;
89- this .parameters = new ArrayList <> (parameters );
97+ this .parameters = parameters == null ? List . of () : List . copyOf (parameters );
9098 this .propagateParams = propagateParams ;
9199 }
92100
@@ -180,7 +188,7 @@ public Parameter[] getParameters() {
180188
181189 @ NonNull
182190 public List <Parameter > getParametersList () {
183- return Collections . unmodifiableList ( parameters ) ;
191+ return parameters ;
184192 }
185193
186194 public String getBuilderId () {
@@ -227,8 +235,9 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
227235
228236 try {
229237
230- // expand the parameters before passing these to the execution, this is to allow any token macro to resolve parameter values
231- List <Parameter > expandedParams = new LinkedList <>();
238+ // expand the parameters before passing these to the execution, this is to allow any token macro to resolve
239+ // parameter values
240+ List <Parameter > expandedParams = new ArrayList <>();
232241
233242 if (propagateParams ) {
234243 final ParametersAction paramsAction = build .getAction (ParametersAction .class );
@@ -365,17 +374,16 @@ public ScriptlerBuilder newInstance(StaplerRequest req, JSONObject formData) {
365374 }
366375
367376 if (builder == null ) {
368- builder = new ScriptlerBuilder (builderId , null , false , Collections . emptyList ());
377+ builder = new ScriptlerBuilder (builderId , null , false , List . of ());
369378 }
370379
371380 return builder .recreateBuilderWithBuilderIdIfRequired ();
372381 }
373382
374383 public List <Script > getScripts () {
375384 // TODO currently only script for RUN_SCRIPT permissions are returned?
376- Set <Script > scripts = getConfig ().getScripts ();
377385 List <Script > scriptsForBuilder = new ArrayList <>();
378- for (Script script : scripts ) {
386+ for (Script script : getConfig (). getScripts () ) {
379387 if (script .nonAdministerUsing ) {
380388 scriptsForBuilder .add (script );
381389 }
0 commit comments