Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for null to be passed to doSafeRestart #9882

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/src/main/java/jenkins/model/Jenkins.java
Original file line number Diff line number Diff line change
Expand Up @@ -4667,40 +4667,40 @@
*/
@Deprecated(since = "2.414")
public HttpResponse doSafeRestart(StaplerRequest req) throws IOException, ServletException, RestartNotSupportedException {
return doSafeRestart(StaplerRequest.toStaplerRequest2(req), null);
return doSafeRestart(req != null ? StaplerRequest.toStaplerRequest2(req) : null, null);
}

/**
* Queues up a safe restart of Jenkins. Jobs have to finish or pause before it can proceed. No new jobs are accepted.
*
* @since 2.475
*/
public HttpResponse doSafeRestart(StaplerRequest2 req, @QueryParameter("message") String message) throws IOException, ServletException, RestartNotSupportedException {
checkPermission(MANAGE);
if (req != null && req.getMethod().equals("GET")) {
return HttpResponses.forwardToView(this, "_safeRestart.jelly");
}

if (req != null && req.getParameter("cancel") != null) {
return doCancelQuietDown();
}

if (req == null || req.getMethod().equals("POST")) {
safeRestart(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);
return doSafeRestart(req != null ? StaplerRequest.toStaplerRequest2(req) : null, message);

Check warning on line 4703 in core/src/main/java/jenkins/model/Jenkins.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 4670-4703 are not covered by tests
} catch (ServletException e) {
throw ServletExceptionWrapper.fromJakartaServletException(e);
}
Expand Down
Loading