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

Remove /exception endpoint #10326

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
9 changes: 0 additions & 9 deletions core/src/main/java/jenkins/model/Jenkins.java
Original file line number Diff line number Diff line change
Expand Up @@ -4467,15 +4467,6 @@ public void doGc(StaplerResponse2 rsp) throws IOException {
rsp.getWriter().println("GCed");
}

/**
* End point that intentionally throws an exception to test the error behaviour.
* @since 1.467
*/
@StaplerDispatchable
public void doException() {
throw new RuntimeException();
}

@Override
public ContextMenu doContextMenu(StaplerRequest2 request, StaplerResponse2 response) throws IOException, JellyException {
ContextMenu menu = new ContextMenu().from(this, request, response);
Expand Down
26 changes: 20 additions & 6 deletions test/src/test/java/jenkins/security/StackTraceSuppressionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
import static org.hamcrest.Matchers.not;

import hudson.model.FreeStyleProject;
import hudson.model.InvisibleAction;
import hudson.model.ItemGroup;
import hudson.model.RootAction;
import hudson.model.TopLevelItemDescriptor;
import hudson.model.User;
import java.io.IOException;
Expand All @@ -41,6 +43,8 @@
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.MockAuthorizationStrategy;
import org.jvnet.hudson.test.TestExtension;
import org.kohsuke.stapler.WebMethod;
import org.xml.sax.SAXException;

public class StackTraceSuppressionTest {
Expand Down Expand Up @@ -129,19 +133,15 @@ public void exceptionShowsTrace() throws Exception {

@Test
public void exceptionEndpoint() throws Exception {
/* This test is based upon a testing endpoint that really shouldn't exist in production code.
If Jenkins is improved to eliminate this endpoint, this test may erroneously fail. */
String relativePath = "exception";
String detailString = "Jenkins.doException";
String detailString = "ExceptionAction.doException";
checkSuppressedStack(relativePath, detailString);
}

@Test
public void exceptionEndpointShowsTrace() throws Exception {
/* This test is based upon a testing endpoint that really shouldn't exist in production code.
If Jenkins is improved to eliminate this endpoint, this test may erroneously fail. */
String relativePath = "exception";
String detailString = "Jenkins.doException";
String detailString = "ExceptionAction.doException";
checkDisplayedStackTrace(relativePath, detailString);
}

Expand Down Expand Up @@ -188,4 +188,18 @@ private void checkDisplayedStackTrace(String relativePath, String detailString)
assertThat(content, containsString(detailString));
}

/* Replacement for historical Jenkins#doException URL */
@TestExtension
public static class ExceptionAction extends InvisibleAction implements RootAction {
@WebMethod(name = "")
public void doException() {
throw new RuntimeException();
}

@Override
public String getUrlName() {
return "exception";
}
}

}
Loading