Noisy warning if restart is required

This commit is contained in:
tfennelly committed 2015-10-02 17:53:47 +01:00
1 parent 433d4375a0
commit 83a8d54904
4 files changed
+51 -2

No files matched your search

+31 -1
View File
@@ -119,6 +119,8 @@ import org.xml.sax.helpers.DefaultHandler;
import static hudson.init.InitMilestone.*;
import hudson.model.DownloadService;
import hudson.util.FormValidation;
import static java.util.logging.Level.SEVERE;
import static java.util.logging.Level.WARNING;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
@@ -803,6 +805,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
*/
public void doInstall(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
boolean dynamicLoad = req.getParameter("dynamicLoad")!=null;
final List<Future<UpdateCenter.UpdateCenterJob>> deployJobs = new ArrayList<>();
Enumeration<String> en = req.getParameterNames();
while (en.hasMoreElements()) {
@@ -835,9 +838,36 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
if (p == null) {
throw new Failure("No such plugin: " + n);
}
p.deploy(dynamicLoad);
deployJobs.add(p.deploy(dynamicLoad));
}
}
// Fire a one-off thread to wait for the plugins to be deployed and then
// refresh the dependant plugins list.
new Thread() {
@Override
public void run() {
INSTALLING: while (true) {
for (Future<UpdateCenter.UpdateCenterJob> deployJob : deployJobs) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
LOGGER.log(SEVERE, "Unexpected error while waiting for some plugins to install. Plugin Manager state may be invalid. Please restart Jenkins ASAP.", e);
}
if (!deployJob.isCancelled() && !deployJob.isDone()) {
// One of the plugins is not installing/canceled, so
// go back to sleep and try again in a while.
continue INSTALLING;
}
}
// All the plugins are installed. It's now safe to refresh.
resolveDependantPlugins();
break;
}
}
}.start();
rsp.sendRedirect("../updateCenter/");
}