Skip to content

Commit 177b452

Browse files
authored
Remove /exception endpoint (#10326)
2 parents 2a88dba + 8fed3af commit 177b452

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

core/src/main/java/jenkins/model/Jenkins.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4478,15 +4478,6 @@ public void doGc(StaplerResponse2 rsp) throws IOException {
44784478
rsp.getWriter().println("GCed");
44794479
}
44804480

4481-
/**
4482-
* End point that intentionally throws an exception to test the error behaviour.
4483-
* @since 1.467
4484-
*/
4485-
@StaplerDispatchable
4486-
public void doException() {
4487-
throw new RuntimeException();
4488-
}
4489-
44904481
@Override
44914482
public ContextMenu doContextMenu(StaplerRequest2 request, StaplerResponse2 response) throws IOException, JellyException {
44924483
ContextMenu menu = new ContextMenu().from(this, request, response);

test/src/test/java/jenkins/security/StackTraceSuppressionTest.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
import static org.hamcrest.Matchers.not;
3030

3131
import hudson.model.FreeStyleProject;
32+
import hudson.model.InvisibleAction;
3233
import hudson.model.ItemGroup;
34+
import hudson.model.RootAction;
3335
import hudson.model.TopLevelItemDescriptor;
3436
import hudson.model.User;
3537
import java.io.IOException;
@@ -41,6 +43,8 @@
4143
import org.junit.Test;
4244
import org.jvnet.hudson.test.JenkinsRule;
4345
import org.jvnet.hudson.test.MockAuthorizationStrategy;
46+
import org.jvnet.hudson.test.TestExtension;
47+
import org.kohsuke.stapler.WebMethod;
4448
import org.xml.sax.SAXException;
4549

4650
public class StackTraceSuppressionTest {
@@ -129,19 +133,15 @@ public void exceptionShowsTrace() throws Exception {
129133

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

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

@@ -188,4 +188,18 @@ private void checkDisplayedStackTrace(String relativePath, String detailString)
188188
assertThat(content, containsString(detailString));
189189
}
190190

191+
/* Replacement for historical Jenkins#doException URL */
192+
@TestExtension
193+
public static class ExceptionAction extends InvisibleAction implements RootAction {
194+
@WebMethod(name = "")
195+
public void doException() {
196+
throw new RuntimeException();
197+
}
198+
199+
@Override
200+
public String getUrlName() {
201+
return "exception";
202+
}
203+
}
204+
191205
}

0 commit comments

Comments
 (0)