From 08409155fb5f4391c0eec34992009ecaaadcdc8c Mon Sep 17 00:00:00 2001 From: Aaron Zurawski Date: Wed, 5 Feb 2020 07:09:58 -0500 Subject: [PATCH] [JENKINS-60884] - Fix NPE in Run API when using getPreviousBuildsOverThreshold (#4471) * Added a null check to getPreviousBuildsOverThreshold. * Cleaned up accidental newline. * Update core/src/main/java/hudson/model/Run.java Co-Authored-By: Zbynek Konecny Co-authored-by: Zbynek Konecny --- core/src/main/java/hudson/model/Run.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/model/Run.java b/core/src/main/java/hudson/model/Run.java index e30988f91df52..22bac37e1f41f 100644 --- a/core/src/main/java/hudson/model/Run.java +++ b/core/src/main/java/hudson/model/Run.java @@ -954,7 +954,10 @@ protected void dropLinks() { */ public @Nonnull List getPreviousBuildsOverThreshold(int numberOfBuilds, @Nonnull Result threshold) { RunT r = getPreviousBuild(); - return r.getBuildsOverThreshold(numberOfBuilds, threshold); + if (r != null) { + return r.getBuildsOverThreshold(numberOfBuilds, threshold); + } + return new ArrayList<>(numberOfBuilds); } /**