Skip to content

Commit

Permalink
Merge pull request #496 from poorlyDefined/JENKINS-71328
Browse files Browse the repository at this point in the history
JENKINS-71328 -- Add handling for events with Null ChangeSet attributes
  • Loading branch information
rsandell committed Oct 6, 2023
2 parents a6c8e07 + b005b53 commit c563987
Showing 1 changed file with 12 additions and 3 deletions.
Expand Up @@ -191,10 +191,19 @@ private boolean shouldIgnoreEvent(ChangeBasedEvent event,
return true;
}

boolean shouldCancelPatchsetNumber = policy.isAbortNewPatchsets()
|| Integer.parseInt(runningChangeBasedEvent.getPatchSet().getNumber())
// events of "type": "topic-changed" are not required to set a PatchSet
boolean hasPatchSets = runningChangeBasedEvent.getPatchSet() != null

Check warning on line 195 in src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/RunningJobs.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 195 is only partially covered, one branch is missing
&& event.getPatchSet() != null;

Check warning on line 196 in src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/RunningJobs.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 196 is only partially covered, one branch is missing

boolean hasPatchNumbers = hasPatchSets && runningChangeBasedEvent.getPatchSet().getNumber() != null

Check warning on line 198 in src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/RunningJobs.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 198 is only partially covered, 2 branches are missing
&& event.getPatchSet().getNumber() != null;

Check warning on line 199 in src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/RunningJobs.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 199 is only partially covered, one branch is missing

boolean isOldPatch = hasPatchSets && hasPatchNumbers

Check warning on line 201 in src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/RunningJobs.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 201 is only partially covered, 2 branches are missing
&& Integer.parseInt(runningChangeBasedEvent.getPatchSet().getNumber())
< Integer.parseInt(event.getPatchSet().getNumber());

boolean shouldCancelPatchsetNumber = policy.isAbortNewPatchsets() || isOldPatch;

boolean isAbortAbandonedPatchset = policy.isAbortAbandonedPatchsets()
&& (event instanceof ChangeAbandoned);

Expand Down Expand Up @@ -304,7 +313,7 @@ public void add(ChangeBasedEvent event) {
* @return true if event was still running.
*/
public boolean remove(ChangeBasedEvent event) {
logger.debug("Removing future job " + event.getPatchSet().getNumber());
logger.debug("Removing future job associated with " + event.getChange().getId());
return runningJobs.remove(event);
}
}

0 comments on commit c563987

Please sign in to comment.