|
29 | 29 | import java.io.IOException; |
30 | 30 | import java.io.Serial; |
31 | 31 | import java.io.Serializable; |
32 | | -import java.util.*; |
| 32 | +import java.util.ArrayList; |
| 33 | +import java.util.HashMap; |
| 34 | +import java.util.List; |
| 35 | +import java.util.Map; |
| 36 | +import java.util.Objects; |
| 37 | +import java.util.Optional; |
33 | 38 | import java.util.concurrent.atomic.AtomicInteger; |
34 | 39 | import java.util.logging.Level; |
35 | 40 | import java.util.logging.Logger; |
@@ -91,19 +96,19 @@ public ScriptlerBuilder( |
91 | 96 | @CheckForNull String builderId, |
92 | 97 | @CheckForNull String scriptId, |
93 | 98 | boolean propagateParams, |
94 | | - Parameter[] parameters) { |
95 | | - this(builderId, scriptId, propagateParams, Arrays.asList(Objects.requireNonNull(parameters))); |
| 99 | + @CheckForNull Parameter[] parameters) { |
| 100 | + this(builderId, scriptId, propagateParams, parameters == null ? List.of() : List.of(parameters)); |
96 | 101 | } |
97 | 102 |
|
98 | 103 | @DataBoundConstructor |
99 | 104 | public ScriptlerBuilder( |
100 | 105 | @CheckForNull String builderId, |
101 | 106 | @CheckForNull String scriptId, |
102 | 107 | boolean propagateParams, |
103 | | - @NonNull List<Parameter> parameters) { |
| 108 | + @CheckForNull List<Parameter> parameters) { |
104 | 109 | this.builderId = builderId; |
105 | 110 | this.scriptId = scriptId; |
106 | | - this.parameters = new ArrayList<>(parameters); |
| 111 | + this.parameters = parameters == null ? List.of() : List.copyOf(parameters); |
107 | 112 | this.propagateParams = propagateParams; |
108 | 113 | } |
109 | 114 |
|
@@ -175,7 +180,7 @@ public Parameter[] getParameters() { |
175 | 180 |
|
176 | 181 | @NonNull |
177 | 182 | public List<Parameter> getParametersList() { |
178 | | - return Collections.unmodifiableList(parameters); |
| 183 | + return parameters; |
179 | 184 | } |
180 | 185 |
|
181 | 186 | public String getBuilderId() { |
@@ -233,7 +238,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen |
233 | 238 |
|
234 | 239 | // expand the parameters before passing these to the execution, this is to allow any token macro to resolve |
235 | 240 | // parameter values |
236 | | - List<Parameter> expandedParams = new LinkedList<>(); |
| 241 | + List<Parameter> expandedParams = new ArrayList<>(); |
237 | 242 |
|
238 | 243 | if (propagateParams) { |
239 | 244 | final ParametersAction paramsAction = build.getAction(ParametersAction.class); |
@@ -371,17 +376,16 @@ public ScriptlerBuilder newInstance(StaplerRequest2 req, JSONObject formData) { |
371 | 376 | } |
372 | 377 |
|
373 | 378 | if (builder == null) { |
374 | | - builder = new ScriptlerBuilder(builderId, null, false, Collections.emptyList()); |
| 379 | + builder = new ScriptlerBuilder(builderId, null, false, List.of()); |
375 | 380 | } |
376 | 381 |
|
377 | 382 | return builder.recreateBuilderWithBuilderIdIfRequired(); |
378 | 383 | } |
379 | 384 |
|
380 | 385 | public List<Script> getScripts() { |
381 | 386 | // TODO currently only script for RUN_SCRIPT permissions are returned? |
382 | | - Set<Script> scripts = getConfig().getScripts(); |
383 | 387 | List<Script> scriptsForBuilder = new ArrayList<>(); |
384 | | - for (Script script : scripts) { |
| 388 | + for (Script script : getConfig().getScripts()) { |
385 | 389 | if (script.nonAdministerUsing) { |
386 | 390 | scriptsForBuilder.add(script); |
387 | 391 | } |
|
0 commit comments