NPE in GroovyScriptEngine.getResourceConnection(String)

View: New views
4 Messages — Rating Filter:   Alert me  

NPE in GroovyScriptEngine.getResourceConnection(String)

by Armin Weißer-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Groovy devs,

i found a NPE GroovyScriptEngine.getResourceConnection(String), when no
script roots has been specified.

Here is a small test.


  @Test(expected =  ResourceException)
  void "execute groovy script on unknown script root should cause some
meaningfull exception"() {
    String[] emptyScriptRoots = []
    GroovyScriptEngine gse = new GroovyScriptEngine(emptyScriptRoots)
    gse.run("unknownScriptName", "")
  }

Instead of getting a meaningfull exception, that the resource
"unknownScriptName" can not be found, I get a NPE, because of an implicit
"throw null" statetement within
GroovyScriptEngine.getResourceConnection(String)

I'm using Groovy 1.6.4.

Cheers,

Armin


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: NPE in GroovyScriptEngine.getResourceConnection(String)

by Guillaume Laforge-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Could you please create a JIRA issue so we don't forget about this?

2009/10/17 Armin Weißer <weisser@...>:

> Hello Groovy devs,
>
> i found a NPE GroovyScriptEngine.getResourceConnection(String), when no
> script roots has been specified.
>
> Here is a small test.
>
>
>  @Test(expected =  ResourceException)
>  void "execute groovy script on unknown script root should cause some
> meaningfull exception"() {
>   String[] emptyScriptRoots = []
>   GroovyScriptEngine gse = new GroovyScriptEngine(emptyScriptRoots)
>   gse.run("unknownScriptName", "")
>  }
>
> Instead of getting a meaningfull exception, that the resource
> "unknownScriptName" can not be found, I get a NPE, because of an implicit
> "throw null" statetement within
> GroovyScriptEngine.getResourceConnection(String)
>
> I'm using Groovy 1.6.4.
>
> Cheers,
>
> Armin
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>



--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: NPE in GroovyScriptEngine.getResourceConnection(String)

by Guillaume Laforge-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Quick look at it, I guess we just need to do
if (se == null) se = new ResourceException("No resource for " +
resourceName + " was found.");
before throwing a null exception, instead.

On Sun, Nov 22, 2009 at 09:41, Guillaume Laforge <glaforge@...> wrote:

> Could you please create a JIRA issue so we don't forget about this?
>
> 2009/10/17 Armin Weißer <weisser@...>:
>> Hello Groovy devs,
>>
>> i found a NPE GroovyScriptEngine.getResourceConnection(String), when no
>> script roots has been specified.
>>
>> Here is a small test.
>>
>>
>>  @Test(expected =  ResourceException)
>>  void "execute groovy script on unknown script root should cause some
>> meaningfull exception"() {
>>   String[] emptyScriptRoots = []
>>   GroovyScriptEngine gse = new GroovyScriptEngine(emptyScriptRoots)
>>   gse.run("unknownScriptName", "")
>>  }
>>
>> Instead of getting a meaningfull exception, that the resource
>> "unknownScriptName" can not be found, I get a NPE, because of an implicit
>> "throw null" statetement within
>> GroovyScriptEngine.getResourceConnection(String)
>>
>> I'm using Groovy 1.6.4.
>>
>> Cheers,
>>
>> Armin
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>   http://xircles.codehaus.org/manage_email
>>
>>
>>
>
>
>
> --
> Guillaume Laforge
> Groovy Project Manager
> Head of Groovy Development at SpringSource
> http://www.springsource.com/g2one
>



--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: NPE in GroovyScriptEngine.getResourceConnection(String)

by Guillaume Laforge-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I've just created the issue:
http://jira.codehaus.org/browse/GROOVY-3893

On Sun, Nov 22, 2009 at 10:51, Guillaume Laforge <glaforge@...> wrote:

> Quick look at it, I guess we just need to do
> if (se == null) se = new ResourceException("No resource for " +
> resourceName + " was found.");
> before throwing a null exception, instead.
>
> On Sun, Nov 22, 2009 at 09:41, Guillaume Laforge <glaforge@...> wrote:
>> Could you please create a JIRA issue so we don't forget about this?
>>
>> 2009/10/17 Armin Weißer <weisser@...>:
>>> Hello Groovy devs,
>>>
>>> i found a NPE GroovyScriptEngine.getResourceConnection(String), when no
>>> script roots has been specified.
>>>
>>> Here is a small test.
>>>
>>>
>>>  @Test(expected =  ResourceException)
>>>  void "execute groovy script on unknown script root should cause some
>>> meaningfull exception"() {
>>>   String[] emptyScriptRoots = []
>>>   GroovyScriptEngine gse = new GroovyScriptEngine(emptyScriptRoots)
>>>   gse.run("unknownScriptName", "")
>>>  }
>>>
>>> Instead of getting a meaningfull exception, that the resource
>>> "unknownScriptName" can not be found, I get a NPE, because of an implicit
>>> "throw null" statetement within
>>> GroovyScriptEngine.getResourceConnection(String)
>>>
>>> I'm using Groovy 1.6.4.
>>>
>>> Cheers,
>>>
>>> Armin
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>   http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>>
>>
>>
>> --
>> Guillaume Laforge
>> Groovy Project Manager
>> Head of Groovy Development at SpringSource
>> http://www.springsource.com/g2one
>>
>
>
>
> --
> Guillaume Laforge
> Groovy Project Manager
> Head of Groovy Development at SpringSource
> http://www.springsource.com/g2one
>



--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email