[
https://issues.apache.org/jira/browse/GROOVY-12667?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18141677#comment-18141677
]
ASF GitHub Bot commented on GROOVY-12667:
-----------------------------------------
testlens-app[bot] commented on PR #3210:
URL: https://github.com/apache/groovy/pull/3210#issuecomment-6755960557
## 🚨 Jobs failed without executing tests 🚨
### Failed Jobs without Test Failures
❌ [jmh-classic /
summary](https://github.com/apache/groovy/actions/runs/42733568358/job/129557539461?pr=3210)
🏷️ Commit: 28ed8f7968cdab7bda00701c7416708754458625
▶️ Tests: 0 executed
🟡 Checks: 26/27 completed
### Rerun Controls
Click the checkbox to trigger a rerun:
🔲 **Rerun jobs**
---
_Learn more about TestLens at
[testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
> Implicit-this call in a DELEGATE_FIRST closure with a null delegate throws
> NullPointerException instead of calling the owner
> ----------------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12667
> URL: https://issues.apache.org/jira/browse/GROOVY-12667
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 4.0.33, 5.0.8, 5.1.3, 6.0.0
> Reporter: Scott Murphy Heiberg
> Priority: Major
>
> {code:groovy}
> class Owner {
> def foo() { 'owner' }
> def test() {
> def c = { -> foo() }
> c.resolveStrategy = Closure.DELEGATE_FIRST
> c.delegate = null
> c()
> }
> }
> assert new Owner().test() == 'owner'
> {code}
> *Actual:* {{java.lang.NullPointerException: Cannot invoke method foo() on
> null object}}. The same happens for OWNER_FIRST with a null owner (the
> delegate is never tried), for a dehydrated closure, and for a method that
> neither candidate has (NPE instead of MissingMethodException). Since
> GROOVY-11858, {{toString()}} in such a closure returns "null" and
> {{is(null)}} returns true, because they run against NullObject.
> *Expected:* a null delegate (or owner) is skipped and the other candidate
> answers, as in Groovy 3 and as property access ({{Closure.getProperty}})
> still does. When neither answers, a MissingMethodException is thrown.
> Cause: GROOVY-7232 removed the {{instanceof GroovyObject}} check from the
> DELEGATE_FIRST and OWNER_FIRST branches of {{ClosureMetaClass.invokeMethod}},
> which also let a null delegate or owner through to
> {{InvokerHelper.invokeMethod(null, ...)}}.
> Verified: 4.0.33, 5.0.8, 6.0.0 and master affected; 3.0.25 and 2.4.15 not
> affected.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)