You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2019/04/05 23:01:00 UTC

[jira] [Updated] (GROOVY-9069) assignment in map by named index causes casting error

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

Paul King updated GROOVY-9069:
------------------------------
    Description: 
If I assign a value to a collection via a named index (key name) I get a casting error like so:

Failed to convert property value of type {{java.util.LinkedHashMap}} to required type {{java.util.Map}} for property {{methodConfigNames}}

Here is the code in question. This doesn't happen in Groovy 2.4.15. Because Grails 4 is running 2.5.6, many plugins are failing with this error.
{code:java}
void setMethodConfigNames(Map<String, Map<String, List<String>>> methodConfigNames) {
    methodConfigNames.each { String key, Map<String, List<String>> value ->
        Map<String, List<ConfigAttribute>> configs = [:]
        populateMap configs, value
        methodConfigs[key] = configs // fails
        //methodConfigs.put(key,configs) // works
    }
}
{code}

If this could get resolved it would save a lot of plugins from having to be re-released with the workaround making less confusion about the error. In some cases this works and some it doesn't. Even though I have @CompileStatic set, the issue happens at runtime.

  was:
If I assign a value to a collection via a named index (key name) I get a casting error like so:

Failed to convert property value of type 'java.util.LinkedHashMap' to required type 'java.util.Map' for property 'methodConfigNames'

Here is the code in question. This doesn't happen in Groovy 2.4.15. Because Grails 4 is running 2.5.6, many plugins are failing with this error.

void setMethodConfigNames(Map<String, Map<String, List<String>>> methodConfigNames) {
 methodConfigNames.each { String key, Map<String, List<String>> value ->

 Map<String, List<ConfigAttribute>> configs = [:]

 populateMap configs, value
 methodConfigs[key] = configs  // fails
 //methodConfigs.put(key,configs) // works
 }
}

If this could get resolved it would save a lot of plugins from having to be re-released with the workaround making less confusion about the error. In some cases this works and some it doesn't. Even though I have @CompileStatic set, the issue happens at runtime.


> assignment in map by named index causes casting error
> -----------------------------------------------------
>
>                 Key: GROOVY-9069
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9069
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 2.5.6
>         Environment: Linux Mint 19.1
>            Reporter: Ryan Vanderwerf
>            Priority: Major
>
> If I assign a value to a collection via a named index (key name) I get a casting error like so:
> Failed to convert property value of type {{java.util.LinkedHashMap}} to required type {{java.util.Map}} for property {{methodConfigNames}}
> Here is the code in question. This doesn't happen in Groovy 2.4.15. Because Grails 4 is running 2.5.6, many plugins are failing with this error.
> {code:java}
> void setMethodConfigNames(Map<String, Map<String, List<String>>> methodConfigNames) {
>     methodConfigNames.each { String key, Map<String, List<String>> value ->
>         Map<String, List<ConfigAttribute>> configs = [:]
>         populateMap configs, value
>         methodConfigs[key] = configs // fails
>         //methodConfigs.put(key,configs) // works
>     }
> }
> {code}
> If this could get resolved it would save a lot of plugins from having to be re-released with the workaround making less confusion about the error. In some cases this works and some it doesn't. Even though I have @CompileStatic set, the issue happens at runtime.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)