groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jochen Theodorou (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (GROOVY-7959) ResourceBundle.getBundle(String, Locale) fails inside Groovy constructor (MissingResourceException)
Date Wed, 05 Oct 2016 12:15:20 GMT

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

Jochen Theodorou resolved GROOVY-7959.
--------------------------------------
    Resolution: Won't Fix
      Assignee: Jochen Theodorou

The problem is that the place of the call to getBundle decides over what classloader is used
to actually look for the resource bundle. In Java this works, because there is nothing in
between. In Groovy there might be the runtime in between. If the runtime is loaded in another
classloader, you may get into trouble here. We cannot completely solve this unless the indy
version of Groovy is used. So instead I suggest you use the getBundle method, which takes
a class loader and give the current class loader (this.class.classloader or in a static context
this.classloader) as third parameter.

> ResourceBundle.getBundle(String, Locale) fails inside Groovy constructor (MissingResourceException)
> ---------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7959
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7959
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-jdk
>    Affects Versions: 2.4.7
>         Environment: Groovy Version: 2.4.7
> JVM: 1.8.0_102
>            Reporter: Jonas Havers
>            Assignee: Jochen Theodorou
>            Priority: Minor
>
> Groovy throws a {{MissingResourceException}} when invoking {{ResourceBundle.getBundle(String,
Locale)}} to get an existing {{ResourceBundle}} inside a constructor.
> {code}
> Caught: java.util.MissingResourceException: Can't find bundle for base name [...]
> {code}
> Please see *[this gist|https://gist.github.com/JonasHavers/45713ba48f85a4e6852d0565e111bca3]*
for an example and the comparison to Java.
> There might be an issue with the {{getBundle(ResourceBundle, String, Locale)}} method
from the {{org.codehaus.groovy.runtime.DefaultGroovyStaticMethods}} class.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message