-
Notifications
You must be signed in to change notification settings - Fork 191
Refactor MutableTreeRevision #21000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Refactor MutableTreeRevision #21000
Conversation
Legioth
commented
Feb 14, 2025
- Rename TreeManipulator to ResultBuilder and use it only for multi-step commands and commands that affect multiple nodes
- Explicitly return a result when handling a command instead of indirectly producing one
- Transactions produce multiple results so they have custom top-level handling instead of following the general pattern
- Handle errors caused by concurrent modifications by returning a Reject result instead of passing the error through an instance field
* Rename TreeManipulator to ResultBuilder and use it only for multi-step commands and commands that affect multiple nodes * Explicitly return a result when handling a command instead of indirectly producing one * Transactions produce multiple results so they have custom top-level handling instead of following the general pattern * Handle errors caused by concurrent modifications by returning a Reject result instead of passing the error through an instance field
| if (mapUpdater.apply(map) instanceof Reject error) { | ||
| return error; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compiler complains about Java 17 compatibility of this expression, considering it to be an unconditional pattern matching instanceof which is supported in Java 21+:
/vaadin/flow/signals/src/main/java/com/vaadin/signals/impl/MutableTreeRevision.java:211:39
java: unconditional patterns in instanceof are not supported in -source 17
(use -source 21 or higher to enable unconditional patterns in instanceof)
Same applies everywhere in this file where (... instanceof Reject error) is used.
Since the updater function is returning CommandResult.Reject, a null check is enough without instanceof.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Silly of Java to not realize that the expression isn't actually unconditional. Uglified to be compatible with ancient compilers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this refactoring going to be back ported to V24 branches, or could the original code with the cleaner instanceof syntax be back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to backport
|
|
Are you working on this or should we close it? |
Test Results1 310 files 1 310 suites 1h 14m 12s ⏱️ Results for commit 50ca9c6. ♻️ This comment has been updated with latest results. |
|
I'm just waiting for someone to review it... |
|


