protect Jenkins against bad RestartListeners
@@ -4463,8 +4463,15 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
// give some time for the browser to load the "reloading" page
Thread.sleep(TimeUnit.SECONDS.toMillis(5));
LOGGER.info(String.format("Restarting VM as requested by %s", exitUser));
- for (RestartListener listener : RestartListener.all())
+ for (RestartListener listener : RestartListener.all()) {
+ try {
listener.onRestart();
+ } catch (Throwable t) {
+ LOGGER.log(Level.WARNING,
+ "RestartListener failed, ignoring and continuing with restart, this indicates a bug in the associated plugin or Jenkins code",
+ t);
+ }
+ }
lifecycle.restart();
} catch (InterruptedException | InterruptedIOException e) {
LOGGER.log(Level.WARNING, "Interrupted while trying to restart Jenkins", e);
