[jira] [Resolved] (GROOVY-7494) ArrayStoreException assigning GStringImpl to String[] when using Indy

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Resolved] (GROOVY-7494) ArrayStoreException assigning GStringImpl to String[] when using Indy

Eric Milles (Jira)

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

Daniel Sun resolved GROOVY-7494.
--------------------------------
    Fix Version/s: 4.0.0-alpha-2
                   3.0.7
         Assignee: Paul King
       Resolution: Fixed

The proposed PR has been merged. Thanks!

> ArrayStoreException assigning GStringImpl to String[] when using Indy
> ---------------------------------------------------------------------
>
>                 Key: GROOVY-7494
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7494
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 2.4.3
>         Environment: Windows 7; Java 8
>            Reporter: Ken Scoggins
>            Assignee: Paul King
>            Priority: Major
>              Labels: indy
>             Fix For: 3.0.7, 4.0.0-alpha-2
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> While upgrading a software baseline from Java 7/Groovy 2.0.2 to Java 8/Groovy 2.4, it appears that assigning a GString with an embedded variable reference to a String array is broken when using Indy. The following example demonstrates this issue:
> {code}
> int a = 1
> String[] fubar = new String[1]
> fubar[0] = "Item $a"
> println fubar
> {code}
> Without Indy, it works just fine:
> {panel}
> /c/test$ groovy GroovyIndyBug.groovy
> [Item 1]
> {panel}
> With Indy, we get the ArrayStoreException
> {panel}
> /c/test$ groovy -indy GroovyIndyBug.groovy
> Caught: java.lang.ArrayStoreException: org.codehaus.groovy.runtime.GStringImpl
> java.lang.ArrayStoreException: org.codehaus.groovy.runtime.GStringImpl
>         at GroovyIndyBug.run(GroovyIndyBug.groovy:3)
> {panel}
> I tried various other assignment methods and this appears to be the only one with the issue.  Oddly, even doing the same assignment, but at creation time instead of after, works just fine.  Some of the other related scenarios I tried are:
> {code}
> int a = 1
> String[] foo = ["Assigned At Creation $a"]
> println foo
> foo[0] = "No Embedded Variable"
> println foo
> foo[0] = "as String $a" as String
> println foo
> foo[0] = "BROKEN $a"
> println foo
> {code}
> With Indy:
> {panel}
> /c/test $ groovy -indy GroovyIndyBug.groovy
> [Assigned At Creation 1]
> [No Embedded Variable]
> [as String 1]
> Caught: java.lang.ArrayStoreException: org.codehaus.groovy.runtime.GStringImpl
> java.lang.ArrayStoreException: org.codehaus.groovy.runtime.GStringImpl
>         at GroovyIndyBug.run(GroovyIndyBug.groovy:12){panel}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)