groovy - 当 Groovy JsonBuilder 尝试序列化 Expando 时,为什么会出现 StackoverflowError?

标签 groovy expando jsonbuilder

当我尝试序列化 Expando 时,出现 StackoverflowError(未追溯到我的代码)。用 groovy shell 复制:

... groovy-2.0.6/bin/groovysh new groovy.json.JsonBuilder(new Expando(name:'hello')).toString()
FATAL: java.lang.StackOverflowError
java.lang.StackOverflowError
        at java.lang.Exception.<init>(Exception.java:77)
        at java.lang.reflect.InvocationTargetException.<init>(InvocationTargetException.java:54)
        at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
...

这应该行得通吗?

最佳答案

哇..这是一个错误。看起来它是在 1.8.8 引入的
在 1.8.6 工作:

groovy-1.8.6/bin/groovysh new groovy.json.JsonBuilder(new Expando(name:'hello')).toString();

===> {"name":"hello"}
1.8.8 处的 StackoverflowError:
groovy-1.8.8/bin/groovysh new groovy.json.JsonBuilder(new Expando(name:'hello')).toString();
FATAL: java.lang.StackOverflowError
java.lang.StackOverflowError
看起来在 2.1.0rc1 上有一个 bug:https://issues.apache.org/jira/browse/GROOVY-5918

关于groovy - 当 Groovy JsonBuilder 尝试序列化 Expando 时,为什么会出现 StackoverflowError?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14406981/

相关文章:

intellij-idea - Groovy 和 IntelliJ : how to extract variable with explicit type declaration?

javascript - 将返回的 Json 响应与发布的响应进行比较

google-app-engine - 应用引擎 : using Expando class in Django NonRel?

json - 如何在 groovy 中修改 JSON

json - 在Groovy中使用jsonbuilder修改json

java - Grails域类字符串列表不存在

grails - 在列表中查找漏洞的常规简单方法?

c# - 如何获取 expando 对象的调用成员名称?

java - Liferay 7 : PermissionChecker not initialized while getting Organization custom field

arrays - 如何在 groovy 中使用 JsonBuilder 创建数组