Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.5
-
JVM: 1.8.0_65 (Oracle)
Mac OS X 10.11.1 (El Capitan)
Description
Using groovy's built-in methods to serialize Joda DateTime to JSON always conclude in a StackOverflowError.
ExampleMethod
package com.mgd import groovy.json.JsonOutput import org.joda.time.DateTime import org.joda.time.format.DateTimeFormat import org.joda.time.format.DateTimeFormatter class JodaBugJson { public static void main(String[] args) { DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS z") DateTime dt = formatter.parseDateTime("2015-11-20 13:37:21.123 EST") //String json = new JsonBuilder(dt).toString() //same outcome String json = JsonOutput.toJson(dt) println json } }
Running the above will result in :
Error
Exception in thread "main" java.lang.StackOverflowError
at org.codehaus.groovy.reflection.ClassInfo.getClassInfo(ClassInfo.java:119)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:261)
at org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:871)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.getMetaPropertyValues(DefaultGroovyMethods.java:364)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.getProperties(DefaultGroovyMethods.java:383)
at groovy.json.JsonOutput.writeObject(JsonOutput.java:290)
at groovy.json.JsonOutput.writeMap(JsonOutput.java:424)
at groovy.json.JsonOutput.writeObject(JsonOutput.java:294)
at groovy.json.JsonOutput.writeMap(JsonOutput.java:424)
at groovy.json.JsonOutput.writeObject(JsonOutput.java:294)
at groovy.json.JsonOutput.writeMap(JsonOutput.java:424)
...
Whether this be only the date, or an object including a Joda DateTime the outcome is the same.
Attachments
Issue Links
- is duplicated by
-
GROOVY-8371 JsonBuilder throws StackOverflow when using java.time.*
- Closed
- is related to
-
GROOVY-10438 DGM: getMetaPropertyValues and getProperties includes private entries
- Closed
- links to