Repository navigation
GROOVY-12665: rehydrate and dehydrate the closure that a curried, writable, composed or trampolined closure wraps - #3186
Closed
codeconsole wants to merge 4 commits into
Closed
codeconsole wants to merge 4 commits into
codeconsole wants to merge 4 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3186 +/- ##
=============================================
Coverage 74.1533% 74.1533%
- Complexity 43751 43756 +5
=============================================
Files 1692 1692
Lines 149516 149524 +8
Branches 28366 28366
=============================================
+ Hits 110871 110877 +6
Misses 28448 28448
- Partials 10197 10199 +2
🚀 New features to boost your workflow:
|
✅ All tests passed ✅🏷️ Commit: f47448d Learn more about TestLens at testlens.app/docs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
rehydrateanddehydrateon a closure wrapper did not reach the closure being wrapped:Closure.rehydrateandClosure.dehydratecopy the closure and replace itsowner,delegateandthisObjectfields.CurriedClosureandClosure.WritableClosurekeep the wrapped closure inowner. Rehydrating replaced it with the new owner, and the next call failed with a ClassCastException. Dehydrating set it to null, and the next call failed with a NullPointerException.ComposedClosureandTrampolineClosurecall through their own fields. Rehydrating them changed nothing that is called, so methods still resolved against the original owner. Dehydrating them left that owner reachable, so the result could not be serialized, which is the reasondehydrateexists.Seen in 4.0.33, 5.0.8 and 6.0.0 too.
Each of the four wrappers now overrides
dehydrate()andrehydrate(Object, Object, Object). The override applies the operation to the wrapped closure (both closures for a composition) and wraps the copy again, so the result behaves like rehydrating the original closure and then currying, composing, trampolining or making it writable. There is one commit per wrapper. Memoized closures are left out: their cache needs a separate decision.Tests
These fail without the change:
ClosureCurryTest.testRehydrateCurriedClosureandtestDehydrateCurriedClosureClosureTest.testDehydrateAndRehydrateWritableClosureClosureComposeTest.testRehydrateComposedClosureandtestDehydrateComposedClosureTrampolineTest.testRehydrateTrampolinedClosureandtestDehydrateTrampolinedClosureThey cover
curry,rcurry,ncurryand nested curry,DELEGATE_FIRST,>>and<<, and serialize, deserialize and rehydrate round trips. Thegroovy.lang.*Closure*,groovy.*Closure*,org.codehaus.groovy.runtime.*Closure*,org.codehaus.groovy.runtime.trampoline.*andorg.codehaus.groovy.runtime.memoize.*tests pass, as doClosuresSTCTest,DelegatesToSTCTest,ClosuresStaticCompileTestandPackedClosuresTransformTest. The Checkstyle and CodeNarc gates pass.