Browse files

[FIXES JENKINS-2494] Restore correct behaviour

- Fixes a regression in core where the display name clear on copy was triggering a save
- More than one way to do this, could also have used the marker interface approach
  This route seems slightly less fragile, though people could still add ItemListeners
  with order == -Double.MAX_VALUE which would then introduce intdeterminism.
  A marker interface would remove that indeterminism as the onCopyComplete method would
  be only called on the Job as the last method... but it could be hard to
  ensure that all ItemGroupMixin's respect the calling of onCopyComplete contract
  hence this approach seems better to me for that reason
  • Loading branch information...
stephenc committed Jul 3, 2013
1 parent 817237d commit 503c3bd2e6f2ec85514e16a260396ddae68f03ae
Showing with 28 additions and 3 deletions.
  1. +28 −3 core/src/main/java/hudson/model/
@@ -125,6 +125,13 @@
private transient volatile boolean holdOffBuildUntilSave;

* {@link ItemListener}s can, and do, modify the job with a corresponding save which will clear
* {@link #holdOffBuildUntilSave} prematurely. The {@link LastItemListener} is responsible for
* clearing this flag as the last item listener.
private transient volatile boolean holdOffBuildUntilUserSave;

private volatile BuildDiscarder logRotator;

@@ -150,7 +157,7 @@ protected Job(ItemGroup parent, String name) {
public synchronized void save() throws IOException {;
holdOffBuildUntilSave = false;
holdOffBuildUntilSave = holdOffBuildUntilUserSave;

@@ -204,7 +211,25 @@ public void onCopiedFrom(Item src) {
synchronized (this) {
this.nextBuildNumber = 1; // reset the next build number
this.holdOffBuildUntilSave = true;
this.holdOffBuildUntilUserSave = true;
this.holdOffBuildUntilSave = this.holdOffBuildUntilUserSave;

@Extension(ordinal = -Double.MAX_VALUE)
public static class LastItemListener extends ItemListener {

public void onCopied(Item src, Item item) {
// If any of the other ItemListeners modify the job, they effect
// a save, which will clear the holdOffBuildUntilUserSave and
// causing a regression of JENKINS-2494
if (item instanceof Job) {
Job job = (Job) item;
synchronized (job) {
job.holdOffBuildUntilUserSave = false;

@@ -226,7 +251,7 @@ protected void performDelete() throws IOException, InterruptedException {
return new TextFile(new File(this.getRootDir(), "nextBuildNumber"));

protected boolean isHoldOffBuildUntilSave() {
protected synchronized boolean isHoldOffBuildUntilSave() {
return holdOffBuildUntilSave;

0 comments on commit 503c3bd

Please sign in to comment.