Skip to content

Conversation

@vaadin-bot
Copy link
Collaborator

This PR cherry-picks changes from the original PR #23401 to branch 24.9.

Original PR description

Previously, TreeData.setParent() only checked for direct self-parenting (item.equals(parent)) but did not detect transitive cycles where a descendant becomes an ancestor. This could corrupt the tree structure, for example when drag-and-drop in TreeGrid moved a parent node under one of its descendants.

Added isAncestorOf() helper method that walks up the ancestor chain to detect if the item being moved is an ancestor of the proposed new parent. If so, setParent() now throws IllegalArgumentException with a clear error message.

The cycle check has O(h) complexity where h is the tree height, which is acceptable for typical tree operations.

Fixes #19337

Previously, TreeData.setParent() only checked for direct self-parenting
(item.equals(parent)) but did not detect transitive cycles where a
descendant becomes an ancestor. This could corrupt the tree structure,
for example when drag-and-drop in TreeGrid moved a parent node under
one of its descendants.

Added isAncestorOf() helper method that walks up the ancestor chain
to detect if the item being moved is an ancestor of the proposed new
parent. If so, setParent() now throws IllegalArgumentException with
a clear error message.

The cycle check has O(h) complexity where h is the tree height, which
is acceptable for typical tree operations.

Fixes #19337
@github-actions github-actions bot added the +0.0.1 label Feb 4, 2026
@vaadin-bot
Copy link
Collaborator Author

This PR is eligible for auto-merging policy, so it has been approved automatically. If there are pending conditions, auto merge (with 'squash' method) has been enabled for this PR[Message is sent from bot]

@vaadin-bot vaadin-bot enabled auto-merge (squash) February 4, 2026 09:08
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 4, 2026

@github-actions
Copy link

github-actions bot commented Feb 4, 2026

Test Results

1 272 files  ± 0  1 272 suites  ±0   1h 13m 5s ⏱️ +36s
8 776 tests + 2  8 713 ✅ + 2  63 💤 ±0  0 ❌ ±0 
9 100 runs   - 55  9 030 ✅  - 56  70 💤 +1  0 ❌ ±0 

Results for commit b2bbc3d. ± Comparison against base commit 398d3ea.

@vaadin-bot vaadin-bot merged commit 0594ff2 into 24.9 Feb 4, 2026
27 of 28 checks passed
@vaadin-bot vaadin-bot deleted the cherry-pick-23401-to-24.9-1770195660913 branch February 4, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants