mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-14 20:42:21 +00:00
JDK 11.0.9 / 8.0.272+ compatible FunctionsTest#printThrowable() (#5033)
* JDK 11.0.9 / 8.0.272+ FunctionsTest#printThrowable() * Ensure proper older java 11 backwards compatibility Co-authored-by: res0nance <res0nance@users.noreply.github.com>
This commit is contained in:
1 parent
b40f70e3d8
commit
e83e6a11dc
1 file changed
+36
-13
@@ -40,6 +40,8 @@ import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import hudson.util.VersionNumber;
|
||||
import jenkins.model.Jenkins;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -510,24 +512,45 @@ public class FunctionsTest {
|
||||
s.println("Some custom exception");
|
||||
}
|
||||
}, "Some custom exception\n", "Some custom exception\n");
|
||||
/* TODO exact format changed in 11.0.9 (JDK-8226809 / JDK-8252444)
|
||||
// Circular references:
|
||||
Stack stack1 = new Stack("p.Exc1", "p.C.method1:17");
|
||||
Stack stack2 = new Stack("p.Exc2", "p.C.method2:27");
|
||||
stack1.cause(stack2);
|
||||
stack2.cause(stack1);
|
||||
assertPrintThrowable(stack1,
|
||||
"p.Exc1\n" +
|
||||
"\tat p.C.method1(C.java:17)\n" +
|
||||
"Caused by: p.Exc2\n" +
|
||||
"\tat p.C.method2(C.java:27)\n" +
|
||||
"\t[CIRCULAR REFERENCE:p.Exc1]\n",
|
||||
"<cycle to p.Exc1>\n" +
|
||||
"Caused: p.Exc2\n" +
|
||||
"\tat p.C.method2(C.java:27)\n" +
|
||||
"Caused: p.Exc1\n" +
|
||||
"\tat p.C.method1(C.java:17)\n");
|
||||
*/
|
||||
//Format changed in 11.0.9 / 8.0.272 (JDK-8226809 / JDK-8252444 / JDK-8252489)
|
||||
if ((getVersion().getDigitAt(0) == 11 && getVersion().isNewerThanOrEqualTo(new VersionNumber("11.0.9"))) ||
|
||||
(getVersion().getDigitAt(0) == 8 && getVersion().isNewerThanOrEqualTo(new VersionNumber("8.0.272")))) {
|
||||
assertPrintThrowable(stack1,
|
||||
"p.Exc1\n" +
|
||||
"\tat p.C.method1(C.java:17)\n" +
|
||||
"Caused by: p.Exc2\n" +
|
||||
"\tat p.C.method2(C.java:27)\n" +
|
||||
"Caused by: [CIRCULAR REFERENCE: p.Exc1]\n",
|
||||
"<cycle to p.Exc1>\n" +
|
||||
"Caused: p.Exc2\n" +
|
||||
"\tat p.C.method2(C.java:27)\n" +
|
||||
"Caused: p.Exc1\n" +
|
||||
"\tat p.C.method1(C.java:17)\n");
|
||||
} else {
|
||||
assertPrintThrowable(stack1,
|
||||
"p.Exc1\n" +
|
||||
"\tat p.C.method1(C.java:17)\n" +
|
||||
"Caused by: p.Exc2\n" +
|
||||
"\tat p.C.method2(C.java:27)\n" +
|
||||
"\t[CIRCULAR REFERENCE:p.Exc1]\n",
|
||||
"<cycle to p.Exc1>\n" +
|
||||
"Caused: p.Exc2\n" +
|
||||
"\tat p.C.method2(C.java:27)\n" +
|
||||
"Caused: p.Exc1\n" +
|
||||
"\tat p.C.method1(C.java:17)\n");
|
||||
}
|
||||
}
|
||||
private static VersionNumber getVersion() {
|
||||
String version = System.getProperty("java.version");
|
||||
if(version.startsWith("1.")) {
|
||||
version = version.substring(2).replace("_", ".");
|
||||
}
|
||||
return new VersionNumber(version);
|
||||
}
|
||||
private static void assertPrintThrowable(Throwable t, String traditional, String custom) {
|
||||
StringWriter sw = new StringWriter();
|
||||
|
||||
Reference in new issue
Block a user