diff --git a/src/test/java/org/json/junit/JSONArrayTest.java b/src/test/java/org/json/junit/JSONArrayTest.java index fd01379..fcaa8ce 100644 --- a/src/test/java/org/json/junit/JSONArrayTest.java +++ b/src/test/java/org/json/junit/JSONArrayTest.java @@ -1474,9 +1474,23 @@ public class JSONArrayTest { @Test public void testRecursiveDepthArrayFor1000Levels() { - ArrayList array = buildNestedArray(1000); - JSONParserConfiguration parserConfiguration = new JSONParserConfiguration().withMaxNestingDepth(1000); - new JSONArray(array, parserConfiguration); + try { + ArrayList array = buildNestedArray(1000); + JSONParserConfiguration parserConfiguration = new JSONParserConfiguration().withMaxNestingDepth(1000); + new JSONArray(array, parserConfiguration); + } catch (StackOverflowError e) { + String javaVersion = System.getProperty("java.version"); + if (javaVersion.startsWith("11.")) { + System.out.println( + "testRecursiveDepthArrayFor1000Levels() allowing intermittent stackoverflow, Java Version: " + + javaVersion); + } else { + String errorStr = "testRecursiveDepthArrayFor1000Levels() unexpected stackoverflow, Java Version: " + + javaVersion; + System.out.println(errorStr); + throw new RuntimeException(errorStr); + } + } } @Test(expected = JSONException.class)