Skip to content

Commit

Permalink
[FIXED JENKINS-31129] Call scheduleBuild only after doConfigSubmit, n…
Browse files Browse the repository at this point in the history
…ot any save.
  • Loading branch information
jglick committed Nov 4, 2015
1 parent a853392 commit 1051362
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
Expand Up @@ -51,7 +51,6 @@
import hudson.model.ModifiableViewGroup;
import hudson.model.TopLevelItem;
import hudson.model.View;
import hudson.model.ViewGroup;
import hudson.model.ViewGroupMixIn;
import hudson.model.listeners.ItemListener;
import hudson.search.CollectionSearchIndex;
Expand Down Expand Up @@ -98,6 +97,7 @@
import org.acegisecurity.context.SecurityContextHolder;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.DoNotUse;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerFallback;
Expand Down Expand Up @@ -657,7 +657,7 @@ public synchronized void doSubmitDescription(StaplerRequest req, StaplerResponse
getPrimaryView().doSubmitDescription(req, rsp);
}

@Restricted(DoNotUse.class)
@Restricted(NoExternalUse.class)
@RequirePOST
public void doConfigSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, Descriptor.FormException {
checkPermission(CONFIGURE);
Expand Down
Expand Up @@ -26,7 +26,6 @@

import com.cloudbees.hudson.plugins.folder.AbstractFolder;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.BulkChange;
import hudson.ExtensionList;
import hudson.XmlFile;
import hudson.model.Action;
Expand Down Expand Up @@ -185,15 +184,10 @@ public void created(I child) {
}, listener);
if (!orphaned.isEmpty()) {
LOGGER.log(Level.FINE, "{0}: orphaned {1}", new Object[] {fullName, orphaned});
BulkChange bc = new BulkChange(this);
try {
for (I existing : orphanedItems(orphaned.values(), listener)) {
LOGGER.log(Level.FINE, "{0}: deleting {1}", new Object[] {fullName, existing});
existing.delete();
// super.onDeleted handles removal from items
}
} finally {
bc.abort(); // ignore calls to save from super.onDeleted
for (I existing : orphanedItems(orphaned.values(), listener)) {
LOGGER.log(Level.FINE, "{0}: deleting {1}", new Object[] {fullName, existing});
existing.delete();
// super.onDeleted handles removal from items
}
}
LOGGER.log(Level.FINE, "finished updating {0}", fullName);
Expand All @@ -213,20 +207,13 @@ private synchronized void loadComputation() {
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to load " + file, e);
}
} else if (isBuildable()) { // first time
scheduleBuild();
}
}

@RequirePOST
@Override
public synchronized void save() throws IOException {
if (BulkChange.contains(this)) {
return;
}
super.save();
// TODO this is problematic, especially when called from super.onDeleted.
// Would be better to get rid of some BulkChange.abort hacks, and call scheduleBuild explicitly
// from various methods which should actually produce changes, like doConfigSubmit.
public void doConfigSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, Descriptor.FormException {
super.doConfigSubmit(req, rsp);
scheduleBuild();
}

Expand Down

0 comments on commit 1051362

Please sign in to comment.