Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find a StackOverflowError in JSONObject.toString() #2749

Closed
ZZemptypoint opened this issue Nov 19, 2022 · 1 comment
Closed

Find a StackOverflowError in JSONObject.toString() #2749

ZZemptypoint opened this issue Nov 19, 2022 · 1 comment
Labels

Comments

@ZZemptypoint
Copy link
Collaborator

版本情况

JDK版本: openjdk_8_201
hutool版本: 5.X.X(请确保最新尝试是否还有问题)

问题描述(包括截图)

  1. 复现代码
		Map<String, Object> map = new HashMap<>(1, 1f);
		Map<String, Object> node = map;
		for (int i = 0; i < 1000; i++) {
			node = (Map<String, Object>) node.computeIfAbsent("a", k -> new HashMap<String, Object>(1, 1f));
		}
		node.put("a", 1);
		String jsonStr = JSONUtil.toJsonStr(map);
		System.out.println(jsonStr);
		JSONObject jsonObject = new JSONObject(jsonStr);
		System.out.println(jsonObject.toString());
  1. 堆栈信息

  2. 测试涉及到的文件(注意脱密)

比如报错的Excel文件,有问题的图片等。

@looly
Copy link
Member

looly commented Nov 29, 2022

这个是节点太多,递归栈溢出了。

暂无解。

考虑从6.x开始改为循环解析。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants