-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #286 from dwnusbaum/isUnserializableException
Prevent StackOverflowError in ErrorAction.isUnserializableError due to cyclic errors
- Loading branch information
Showing
2 changed files
with
23 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
@@ -46,6 +47,7 @@ | |
import org.jvnet.hudson.test.Issue; | ||
import org.jvnet.hudson.test.JenkinsSessionRule; | ||
|
||
import groovy.lang.MissingMethodException; | ||
import hudson.Functions; | ||
import hudson.model.Result; | ||
import hudson.remoting.ProxyException; | ||
|
@@ -227,4 +229,20 @@ public static class X extends Exception { | |
}); | ||
} | ||
|
||
@Test public void cyclicErrorsAreSupported() throws Throwable { | ||
Exception cyclic1 = new Exception(); | ||
Exception cyclic2 = new Exception(cyclic1); | ||
cyclic1.initCause(cyclic2); | ||
assertNotNull(new ErrorAction(cyclic1)); | ||
assertNotNull(new ErrorAction(cyclic2)); | ||
} | ||
|
||
@Ignore("TODO: broken until https://github.com/jenkinsci/remoting/pull/645 is picked up") | ||
Check warning on line 240 in src/test/java/org/jenkinsci/plugins/workflow/actions/ErrorActionTest.java
|
||
@Test public void unserializableCyclicErrorsAreSupported() throws Throwable { | ||
Exception unserializable = new MissingMethodException("thisMethodDoesNotExist", String.class, new Object[0]); | ||
Exception cyclic = new Exception(unserializable); | ||
unserializable.initCause(cyclic); | ||
assertNotNull(new ErrorAction(unserializable)); | ||
assertNotNull(new ErrorAction(cyclic)); | ||
} | ||
} |