Skip to content

Commit 564dc8b

Browse files
grmblfrzSwen Thümmler
andauthored
ConfigurationAsCode::collectProblems: add check for null key in issue… (#2316)
Co-authored-by: Swen Thümmler <[email protected]>
1 parent d725a72 commit 564dc8b

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

plugin/src/main/java/io/jenkins/plugins/casc/ConfigurationAsCode.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import java.util.List;
5959
import java.util.Map;
6060
import java.util.Objects;
61+
import java.util.Optional;
6162
import java.util.Scanner;
6263
import java.util.Set;
6364
import java.util.TreeSet;
@@ -262,7 +263,13 @@ public FormValidation doCheckNewSource(@QueryParameter String newSource) {
262263
private JSONArray collectProblems(Map<Source, String> issues, String severity) {
263264
final JSONArray problems = new JSONArray();
264265
issues.entrySet().stream()
265-
.map(e -> new JSONObject().accumulate("line", e.getKey().line).accumulate(severity, e.getValue()))
266+
.map(e -> new JSONObject()
267+
.accumulate(
268+
"line",
269+
Optional.ofNullable(e.getKey())
270+
.map(it -> it.line)
271+
.orElse(-1))
272+
.accumulate(severity, e.getValue()))
266273
.forEach(problems::add);
267274
return problems;
268275
}

0 commit comments

Comments
 (0)