Skip to content

Commit da41f6b

Browse files
authored
[JENKINS-75091] Fix null pointer exception when title is missing (jenkinsci#169)
https://issues.jenkins.io/browse/JENKINS-75091 provides a sample Pipeline that throws a null pointer exception when viewing plots after a few executions of the job. pipeline { agent { label 'linux' } stages { stage('Hello') { steps { echo 'Hello World' sh '''#!/bin/bash [ ! -f plot-a.csv ] && echo "Line-A,Line-B" > plot-a.csv let "OTHER_VAR=2*BUILD_ID+1" echo $BUILD_ID,$OTHER_VAR >> plot-a.csv ''' plot csvFileName: 'plot-923ffed9-0b83-4a7d-93eb-55894c27e904.csv', csvSeries: [[file: 'plot-a.csv']], group: 'Z-group', style: 'line' plot csvFileName: 'plot-923ffed9-0b83-4a7d-93eb-111111111111.csv', csvSeries: [[file: 'plot-a.csv']], group: 'Z-group', style: 'line' } } } }
1 parent 81a319a commit da41f6b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/main/java/hudson/plugins/plot/Plot.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,12 @@ public Double getDoubleFromString(String input) {
425425
}
426426

427427
public int compareTo(Plot o) {
428+
if (title == null) {
429+
return o == null || o.getTitle() == null ? 0 : -1;
430+
}
431+
if (o == null || o.getTitle() == null) {
432+
return 1;
433+
}
428434
return title.compareTo(o.getTitle());
429435
}
430436

0 commit comments

Comments
 (0)