feat: add cloning fail fast check#2131
Merged
triceo merged 6 commits intoTimefoldAI:1.xfrom Feb 19, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a fail-fast validation to the deep-cloning subsystem to prevent invalid configurations where a basic planning variable is marked for deep cloning but its value type is not deep-clonable, and it adds a regression test plus minimal testdomain classes to cover the scenario.
Changes:
- Add a fail-fast
IllegalStateExceptioninDeepCloningUtils.isFieldDeepCloned(...)for@PlanningVariable+@DeepPlanningClonefields whose type is not deep-cloned. - Introduce a dedicated invalid testdomain entity/solution that reproduces the configuration mistake.
- Add a unit test asserting the new error message guidance.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| core/src/main/java/ai/timefold/solver/core/impl/domain/solution/cloner/DeepCloningUtils.java | Adds the new validation and a helper to detect basic planning variables via field/getter annotations. |
| core/src/test/java/ai/timefold/solver/core/impl/domain/solution/cloner/AbstractSolutionClonerTest.java | Adds a regression test asserting fail-fast behavior and message content. |
| core/src/test/java/ai/timefold/solver/core/testdomain/clone/deepcloning/field/invalid/TestdataInvalidEntityProvidingSolution.java | New test solution used to trigger the invalid deep-clone configuration. |
| core/src/test/java/ai/timefold/solver/core/testdomain/clone/deepcloning/field/invalid/TestdataInvalidEntityProvidingEntity.java | New test entity with @PlanningVariable and a deliberately invalid @DeepPlanningClone setup. |
triceo
approved these changes
Feb 19, 2026
0adb0e3 to
ef671f1
Compare
...est/java/ai/timefold/solver/core/impl/domain/solution/cloner/AbstractSolutionClonerTest.java
Outdated
Show resolved
Hide resolved
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.
No description provided.