-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
125 additions
and
13 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
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
2 changes: 2 additions & 0 deletions
2
hutool-json/src/test/java/Issue2555Test.java → ...st/java/cn/hutool/json/Issue2555Test.java
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
23 changes: 23 additions & 0 deletions
23
hutool-json/src/test/java/cn/hutool/json/Issue2746Test.java
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cn.hutool.json; | ||
|
||
import cn.hutool.core.util.StrUtil; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class Issue2746Test { | ||
@Test | ||
public void parseObjTest() { | ||
final String str = StrUtil.repeat("{", 1500) + StrUtil.repeat("}", 1500); | ||
try{ | ||
JSONUtil.parseObj(str); | ||
} catch (final JSONException e){ | ||
Assert.assertTrue(e.getMessage().startsWith("A JSONObject can not directly nest another JSONObject or JSONArray")); | ||
} | ||
} | ||
|
||
@Test(expected = JSONException.class) | ||
public void parseTest() { | ||
final String str = StrUtil.repeat("[", 1500) + StrUtil.repeat("]", 1500); | ||
JSONUtil.parseArray(str); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
hutool-json/src/test/java/cn/hutool/json/Issue2749Test.java
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package cn.hutool.json; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class Issue2749Test { | ||
|
||
@Test | ||
@Ignore | ||
public void jsonObjectTest() { | ||
final Map<String, Object> map = new HashMap<>(1, 1f); | ||
Map<String, Object> node = map; | ||
for (int i = 0; i < 1000; i++) { | ||
//noinspection unchecked | ||
node = (Map<String, Object>) node.computeIfAbsent("a", k -> new HashMap<String, Object>(1, 1f)); | ||
} | ||
node.put("a", 1); | ||
final String jsonStr = JSONUtil.toJsonStr(map); | ||
|
||
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection") | ||
final JSONObject jsonObject = new JSONObject(jsonStr); | ||
Assert.assertNotNull(jsonObject); | ||
|
||
// 栈溢出 | ||
//noinspection ResultOfMethodCallIgnored | ||
jsonObject.toString(); | ||
} | ||
} |