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

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

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

   ## ✅ All tests passed ✅
   
   🏷️ Commit: 2a73ac9b70bd4ddafd83aab20b87fcacc70d1ee7
   ▶️ Tests:  122895 executed
   ⚪️ Checks: 27/27 completed
   
   ---
   _Learn more about TestLens at 
[testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
   




> memoizeAtMost, memoizeAtLeast and memoizeBetween closures cannot be 
> serialized, unlike memoize closures
> -------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12674
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12674
>             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 roundTrip(Closure c) {
>     def bytes = new ByteArrayOutputStream()
>     bytes.withObjectOutputStream { it.writeObject(c) }
>     new 
> ByteArrayInputStream(bytes.toByteArray()).withObjectInputStream(getClass().classLoader)
>  { it.readObject() }
> }
> def base = { x -> x * 2 }.dehydrate()
> assert roundTrip(base.memoize())(4) == 8      // works
> roundTrip(base.memoizeAtMost(2))               // NotSerializableException: 
> org.codehaus.groovy.runtime.memoize.LRUCache
> roundTrip(base.memoizeAtLeast(0))              // NotSerializableException: 
> org.codehaus.groovy.runtime.memoize.NullProtectionStorage
> roundTrip(base.memoizeAtLeast(2))              // NotSerializableException: 
> java.lang.ref.ReferenceQueue
> def between = base.memoizeBetween(1, 3)
> between(1)
> roundTrip(between)                             // NotSerializableException: 
> java.lang.ref.SoftReference
> {code}
> *Actual:* every variant except memoize() throws NotSerializableException, 
> whether or not it has been called.
> *Expected:* they serialize like memoize() does and still memoize after 
> deserialization, with the same limits.
> Cause: LRUCache is not Serializable. The soft reference variants hold a 
> ReferenceQueue, a NullProtectionStorage or LRUProtectionStorage, and 
> SoftReference cache values, none of which can be serialized.
> 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