You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/12/18 15:37:00 UTC

[jira] [Updated] (GROOVY-3250) StackOverflowError in List and Map formatting

     [ https://issues.apache.org/jira/browse/GROOVY-3250?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles updated GROOVY-3250:
--------------------------------
    Labels: StackOverflowError  (was: )

> StackOverflowError in List and Map formatting
> ---------------------------------------------
>
>                 Key: GROOVY-3250
>                 URL: https://issues.apache.org/jira/browse/GROOVY-3250
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-jdk
>    Affects Versions: 1.5.7
>         Environment: Groovy 1.5.7 and 1.6-RC1
>            Reporter: Alexander Veit
>            Priority: Major
>              Labels: StackOverflowError
>
> If a List or Map that contains itself is formatted for output (print, inspect,...) a StackOverflowError occurs.
> {code}
> import org.codehaus.groovy.runtime.InvokerHelper
> def x
> // List (simple case)
> x = []
> x << x
> assert "[(this Collection)]" == x.toString()
> InvokerHelper.toListString(x)
> // List (nested case)
> x = []
> x << [x]
> assert InvokerHelper.toListString(x)
> // Map (simple case)
> x = [:]
> x.put("self", x)
> assert "[self:this Map_]" == InvokerHelper.toMapString(x) // JDK uses "(this Map)"
> // Map (nested case)
> x = [:]
> x.put("nested", ["self":x])
> assert InvokerHelper.toMapString(x)
> // there are also List/Map mixed cases
> // ...
> {code}
> See also GROOVY-1106.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)