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

JSON.json(Locale) throw StackOverflowError, into the dead loop #400

Closed
takeseem opened this issue Mar 14, 2017 · 2 comments
Closed

JSON.json(Locale) throw StackOverflowError, into the dead loop #400

takeseem opened this issue Mar 14, 2017 · 2 comments

Comments

@takeseem
Copy link
Contributor

public class JSONTest {
	
	@Test
	public void testLocale() throws Exception {
		Locale locale = Locale.US;
		String result = JSON.json(locale);
		//check JSON.json(Locale) into the dead loop
		/**
		java.lang.StackOverflowError
			at java.lang.StringBuilder.append(StringBuilder.java:136)
			at sun.util.locale.provider.LocaleResources.getLocaleName(LocaleResources.java:230)
			at java.util.Locale.getDisplayName(Locale.java:1879)
			at java.util.Locale.getDisplayName(Locale.java:1845)
			at com.alibaba.dubbo.common.bytecode.Wrapper1.getPropertyValue(Wrapper1.java)
			at com.alibaba.dubbo.common.json.GenericJSONConverter.writeValue(GenericJSONConverter.java:126)
			at com.alibaba.dubbo.common.json.GenericJSONConverter.writeValue(GenericJSONConverter.java:73)
			at com.alibaba.dubbo.common.json.GenericJSONConverter.writeValue(GenericJSONConverter.java:130)
			at com.alibaba.dubbo.common.json.GenericJSONConverter.writeValue(GenericJSONConverter.java:73)
			at com.alibaba.dubbo.common.json.GenericJSONConverter.writeValue(GenericJSONConverter.java:130)
			at com.alibaba.dubbo.common.json.GenericJSONConverter.writeValue(GenericJSONConverter.java:73)
			at com.alibaba.dubbo.common.json.GenericJSONConverter.writeValue(GenericJSONConverter.java:130)
		 */
		Assert.assertEquals(result, locale.toString());
	}
takeseem added a commit to takeseem-com/dubbo that referenced this issue Mar 14, 2017
takeseem added a commit to takeseem-com/dubbo that referenced this issue Nov 22, 2017
@takeseem
Copy link
Contributor Author

fix from dubbo:master, 2.5.7 : GenericJSONConverter主要是用在日志部分输出,所以当我们输出locale对象时就发生stack溢出。

java.lang.StackOverflowError
	at com.alibaba.dubbo.common.json.JSONWriter.valueString(JSONWriter.java:189)
	at com.alibaba.dubbo.common.json.GenericJSONConverter$7.encode(GenericJSONConverter.java:100)
	at com.alibaba.dubbo.common.json.GenericJSONConverter.writeValue(GenericJSONConverter.java:338)
	at com.alibaba.dubbo.common.json.GenericJSONConverter.writeValue(GenericJSONConverter.java:347)
	at com.alibaba.dubbo.common.json.GenericJSONConverter.writeValue(GenericJSONConverter.java:395)
	at com.alibaba.dubbo.common.json.GenericJSONConverter.writeValue(GenericJSONConverter.java:347)
	at com.alibaba.dubbo.common.json.GenericJSONConverter.writeValue(GenericJSONConverter.java:395)

@takeseem
Copy link
Contributor Author

#906

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

No branches or pull requests

1 participant