[
https://issues.apache.org/jira/browse/GROOVY-12671?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18137528#comment-18137528
]
ASF GitHub Bot commented on GROOVY-12671:
-----------------------------------------
testlens-app[bot] commented on PR #3192:
URL: https://github.com/apache/groovy/pull/3192#issuecomment-6613417949
## ✅ All tests passed ✅
🏷️ Commit: 6c29d899c8c64811e851b94af40a1e89b619115c
▶️ Tests: 125072 executed
⚪️ Checks: 27/27 completed
---
_Learn more about TestLens at
[testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
> Closure property access throws NullPointerException instead of falling
> through to the delegate when the owner is null
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12671
> URL: https://issues.apache.org/jira/browse/GROOVY-12671
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 4.0.33, 5.0.8, 7.0.0-alpha-1, 6.0.0
> Reporter: Scott Murphy Heiberg
> Priority: Major
>
> {code:groovy}
> class D { def bar = 'delegate' }
> def c = { -> bar }.dehydrate()
> c.delegate = new D()
> assert c() == 'delegate'
> {code}
> *Actual:* {{java.lang.NullPointerException: Cannot get property 'bar' on null
> object}}. A write ({{bar = 1}}) throws {{Cannot set property 'bar' on null
> object}}, and so does {{rehydrate(d, null, null)}}.
> *Expected:* with OWNER_FIRST (the default) a null owner is skipped and the
> delegate supplies the property, the same as for method calls (GROOVY-12667).
> When no non-null candidate remains (both null, or a null target under
> OWNER_ONLY or DELEGATE_ONLY), MissingPropertyException is thrown, matching
> the MissingMethodException that method calls give.
> {{Closure.resolveGetProperty}} and {{resolveSetProperty}} skip a null
> receiver only for DELEGATE_FIRST with a null delegate (GROOVY-1974). Every
> other null receiver reaches {{NullObject}}. Separately,
> {{setPropertyTryThese}} tests {{o1 != null}} where it should test {{o2 !=
> null}}, so a missing property on the owner with a null delegate also throws
> NPE instead of MissingPropertyException.
> Verified on 2.4.15, 3.0.25, 4.0.33, 5.0.8, 6.0.0 and master.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)