diff --git a/core/src/main/java/jenkins/cli/SafeRestartCommand.java b/core/src/main/java/jenkins/cli/SafeRestartCommand.java index 54c624bbba27..4c1a8009e44d 100644 --- a/core/src/main/java/jenkins/cli/SafeRestartCommand.java +++ b/core/src/main/java/jenkins/cli/SafeRestartCommand.java @@ -32,6 +32,7 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; import org.kohsuke.args4j.Option; +import org.kohsuke.stapler.StaplerRequest2; /** * Safe Restart Jenkins - do not accept any new jobs and try to pause existing. @@ -53,7 +54,7 @@ public String getShortDescription() { @Override protected int run() throws Exception { - Jenkins.get().doSafeRestart(null, message); + Jenkins.get().doSafeRestart((StaplerRequest2) null, message); return 0; } } diff --git a/core/src/main/java/jenkins/model/Jenkins.java b/core/src/main/java/jenkins/model/Jenkins.java index 705044cd8fa0..d3257fb42e09 100644 --- a/core/src/main/java/jenkins/model/Jenkins.java +++ b/core/src/main/java/jenkins/model/Jenkins.java @@ -4665,7 +4665,7 @@ public HttpResponse doSafeRestart(StaplerRequest req) throws IOException, Servle /** * Queues up a safe restart of Jenkins. Jobs have to finish or pause before it can proceed. No new jobs are accepted. * - * @since 2.414 + * @since 2.475 */ public HttpResponse doSafeRestart(StaplerRequest2 req, @QueryParameter("message") String message) throws IOException, ServletException, RestartNotSupportedException { checkPermission(MANAGE); @@ -4684,6 +4684,20 @@ public HttpResponse doSafeRestart(StaplerRequest2 req, @QueryParameter("message" return HttpResponses.redirectToDot(); } + /** + * @deprecated use {@link #doSafeRestart(StaplerRequest2, String)} + * @since 2.414 + */ + @Deprecated + @StaplerNotDispatchable + public HttpResponse doSafeRestart(StaplerRequest req, @QueryParameter("message") String message) throws IOException, javax.servlet.ServletException, RestartNotSupportedException { + try { + return doSafeRestart(StaplerRequest.toStaplerRequest2(req), message); + } catch (ServletException e) { + throw ServletExceptionWrapper.fromJakartaServletException(e); + } + } + private static Lifecycle restartableLifecycle() throws RestartNotSupportedException { if (Main.isUnitTest) { throw new RestartNotSupportedException("Restarting the controller JVM is not supported in JenkinsRule-based tests");