Skip to content
Permalink
Browse files

Merge pull request #23 from jglick/schedule-on-submit-JENKINS-31129

[JENKINS-31129] Call scheduleBuild only after doConfigSubmit, not any save
  • Loading branch information...
jglick committed Nov 4, 2015
2 parents 725e2c0 + 1051362 commit 9cbe993366137de106dbab2cfb7dfc51433324c8
@@ -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;
@@ -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;
@@ -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);
@@ -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;
@@ -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);
@@ -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();
}

0 comments on commit 9cbe993

Please sign in to comment.
You can’t perform that action at this time.