[
https://issues.apache.org/jira/browse/GROOVY-7709?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15072024#comment-15072024
]
ASF GitHub Bot commented on GROOVY-7709:
----------------------------------------
GitHub user jwagenleitner opened a pull request:
https://github.com/apache/groovy/pull/226
GROOVY-7709 - ConvertedClosure/ConvertedMap do not work with interface
extending GroovyObject
Just posting for discussion and acknowledge that there is probably a better
fix and lots here is not being addressed other the immediate issue. For this
fix I borrowed from what was done in `GroovyResultSetProxy`.
Assuming this is even somewhat close to the right way to address it, it
might make sense for the `ConvertedMap` to handle the metaClass in case the map
has a `getMetaClass` key.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/jwagenleitner/groovy GROOVY-7709
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/groovy/pull/226.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #226
----
commit 584840327d484e9a24fd69a3cfc8a8c97fa55e86
Author: John Wagenleitner <[email protected]>
Date: 2015-12-27T03:17:07Z
GROOVY-7709 - ConvertedClosure/ConvertedMap do not work with interface
extending GroovyObject
----
> NPE with ConvertedClosure
> -------------------------
>
> Key: GROOVY-7709
> URL: https://issues.apache.org/jira/browse/GROOVY-7709
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 2.4.5
> Reporter: Jochen Theodorou
>
> {code}
> interface Y extends GroovyObject {}
> def cl = {println 1} as Y
> assert cl instanceof GroovyObject
> if (cl) println "!cl"
> {code}
> the code above will cause the execution of the method getMetaClass in the
> boolean part of the "if". It looks like this code path now produces a NPE
> {code}
> java.lang.NullPointerException
> at
> org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:919)
> at
> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:902)
> at
> org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToBoolean(DefaultTypeTransformation.java:185)
> at
> org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.booleanUnbox(DefaultTypeTransformation.java:74){code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)