groovy

NPE in GroovyScriptEngine.getResourceConnection(String)

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.6.4, 1.7-beta-2
  • Fix Version/s: 1.6.6, 1.7-rc-1
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    0

Description

From Armin on the mailing-list:

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.

Activity

Hide
Roshan Dawrani added a comment -

I am in front of the code right now. Shall I put your suggested fix in (on dev list)?

Show
Roshan Dawrani added a comment - I am in front of the code right now. Shall I put your suggested fix in (on dev list)?
Hide
Guillaume Laforge added a comment -

Ah well, okay, go ahead
You can add a similar test as suggested by Armin too then.

Show
Guillaume Laforge added a comment - Ah well, okay, go ahead You can add a similar test as suggested by Armin too then.
Hide
Roshan Dawrani added a comment -

Fixed

Show
Roshan Dawrani added a comment - Fixed

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: