[ 
https://issues.apache.org/jira/browse/GROOVY-12677?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18137516#comment-18137516
 ] 

ASF GitHub Bot commented on GROOVY-12677:
-----------------------------------------

testlens-app[bot] commented on PR #3198:
URL: https://github.com/apache/groovy/pull/3198#issuecomment-6612913772

   ## 🚨 All tests passed but jobs failed 🚨
   
   ### Failed Jobs without Test Failures
   
   ❌ [Build and test / lts \(17, 
macos-latest\)](https://github.com/apache/groovy/actions/runs/41689549039/job/126104247983?pr=3198)
   
   🏷️ Commit: ead2ca7d673fa201fe79b74cf24777e16268b3c3
   ▶️ Tests:  111670 executed
   🟡 Checks: 23/25 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/)._
   




> 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, 7.0.0-alpha-1, 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)

Reply via email to