From 671a7637da5d0f7afad973cd7afd9684e4bacda7 Mon Sep 17 00:00:00 2001 From: Markus Winter Date: Sun, 28 Dec 2025 23:17:04 +0100 Subject: [PATCH] Avoid NPE in Job#getLastBuildsOverThreshold Found while working with calendar-view plugin. Change #4259 introduced a potential NPE in Job#getLastBuildsOverThreshold when a job has no runs. calendar-view plugin is the only user of that method it seems --- core/src/main/java/hudson/model/Job.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/main/java/hudson/model/Job.java b/core/src/main/java/hudson/model/Job.java index 30fafc121b95..278038db9b5b 100644 --- a/core/src/main/java/hudson/model/Job.java +++ b/core/src/main/java/hudson/model/Job.java @@ -1053,6 +1053,9 @@ public RunT getLastCompletedBuild() { */ public List getLastBuildsOverThreshold(int numberOfBuilds, Result threshold) { RunT r = getLastBuild(); + if (r == null) { + return Collections.emptyList(); + } return r.getBuildsOverThreshold(numberOfBuilds, threshold); }