Conversation
reiern70
force-pushed
the
improve-ldms
branch
from
September 23, 2026 17:18
9ce30a9 to
40270ea
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1615 +/- ##
=========================================
Coverage 61.89% 61.89%
- Complexity 11242 11245 +3
=========================================
Files 1247 1247
Lines 48367 48372 +5
Branches 6788 6788
=========================================
+ Hits 29935 29941 +6
Misses 15725 15725
+ Partials 2707 2706 -1 🚀 New features to boost your workflow:
|
detach() drives the model's attach/detach state machine: it invokes onDetach() when there is something to detach, then discards the transient object and resets the state. It was overridable, so a subclass could run cleanup on either side of super.detach(), or skip the super call and leave the model attached for good. Nothing enforced the invariant the method exists to maintain. detach() is now final, and cleanup goes into one of two hooks: onDetach() - as before, only when the model was attached onDetachAlways() - on every detach() call, attached or not onDetachAlways() is what an override of detach() in practice was, and is where cleanup not tied to the loaded object belongs: detaching models this one was handed, for instance, which may have been attached without this model ever loading. A subclass that needed the loaded object while detaching had to keep a reference of its own, because onDetach() took no arguments and the field holding the object is private. The new onDetach(T object) is handed that object before it is discarded. The default onDetach() delegates to it, so an override of onDetach() that does not call super suppresses it. Making a public method final is source-incompatible, which is why this lands on master only. It stays binary compatible - detach() still resolves, on LoadableDetachableModel - so compiled subclasses keep running, but a subclass that overrides detach() no longer compiles. Moving the override's body to onDetachAlways() and dropping the super.detach() call reproduces the old behaviour exactly; moving it to onDetach() narrows it to the attached case. That rewrite needs a judgement about which hook applies, so it is documented as a manual step in wicket.yml rather than automated. Three subclasses in the tree overrode detach(), each to detach something unconditionally, and all three move to onDetachAlways(): StringResourceModel and its AssignmentWrapper, and the devutils SessionIdentifiersModel. StringResourceModel is the reason onDetachAlways() exists at all - per WICKET-5176 it has to detach its substitution models even when it was never attached itself, which an attached-only hook cannot do. Its override stays final, as detach() was, so a subclass cannot quietly drop that cleanup. GitHub issue #1614: #1614
reiern70
force-pushed
the
improve-ldms
branch
from
September 23, 2026 19:33
8164038 to
e64a2bf
Compare
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.
detach() drives the model's attach/detach state machine: it invokes onDetach() when there is something to detach, then discards the transient object and resets the state. It was overridable, so a subclass could run cleanup on either side of super.detach(), or skip the super call and leave the model attached for good. Nothing enforced the invariant the method exists to maintain.
detach() is now final, and cleanup goes into one of two hooks:
onDetach() - as before, only when the model was attached
onDetachAlways() - on every detach() call, attached or not
onDetachAlways() is what an override of detach() in practice was, and is where cleanup not tied to the loaded object belongs: detaching models this one was handed, for instance, which may have been attached without this model ever loading.
A subclass that needed the loaded object while detaching had to keep a reference of its own, because onDetach() took no arguments and the field holding the object is private. The new onDetach(T object) is handed that object before it is discarded. The default onDetach() delegates to it, so an override of onDetach() that does not call super suppresses it.
Making a public method final is source-incompatible, which is why this lands on master only. It stays binary compatible - detach() still resolves, on LoadableDetachableModel - so compiled subclasses keep running, but a subclass that overrides detach() no longer compiles. Moving the override's body to onDetachAlways() and dropping the super.detach() call reproduces the old behaviour exactly; moving it to onDetach() narrows it to the attached case. That rewrite needs a judgement about which hook applies, so it is documented as a manual step in wicket.yml rather than automated.
Three subclasses in the tree overrode detach(), each to detach something unconditionally, and all three move to onDetachAlways(): StringResourceModel and its AssignmentWrapper, and the devutils SessionIdentifiersModel. StringResourceModel is the reason onDetachAlways() exists at all - per WICKET-5176 it has to detach its substitution models even when it was never attached itself, which an attached-only hook cannot do.
GitHub issue #1614: #1614