[
https://issues.apache.org/jira/browse/GROOVY-12677?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18137639#comment-18137639
]
ASF GitHub Bot commented on GROOVY-12677:
-----------------------------------------
testlens-app[bot] commented on PR #3198:
URL: https://github.com/apache/groovy/pull/3198#issuecomment-6618045070
## ✅ All tests passed ✅
🏷️ Commit: fd5a5618642f3a46fcfad9838b3c80b306b5df73
▶️ Tests: 111332 executed
⚪️ Checks: 27/27 completed
---
_Learn more about TestLens at
[testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
> A memoize() closure that has cached a null result cannot be serialized
> ----------------------------------------------------------------------
>
> Key: GROOVY-12677
> URL: https://issues.apache.org/jira/browse/GROOVY-12677
> 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}
> def m = { x -> null }.dehydrate().memoize()
> assert m(1) == null
> def bytes = new ByteArrayOutputStream()
> bytes.withObjectOutputStream { it.writeObject(m) } // fails here
> def copy = new
> ByteArrayInputStream(bytes.toByteArray()).withObjectInputStream(getClass().classLoader)
> { it.readObject() }
> assert copy(1) == null
> {code}
> *Actual:* {{java.io.NotSerializableException:
> org.codehaus.groovy.runtime.memoize.Memoize$MemoizeNullValue}}. The same
> closure serializes when its cached results are not null.
> *Expected:* the memoized closure serializes. The copy returns null for the
> cached arguments without calling the wrapped closure again.
> The memoizing closure stores a null result as a private place-holder,
> {{Memoize.MemoizeNullValue}}, which is not {{Serializable}}. The closure
> recognises the place-holder by identity, so a deserialized copy must also
> resolve back to the shared instance.
> Verified on 4.0.33, 5.0.8, 6.0.0 and master.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)