Skip to content

Port changes from #449 about root preservation#461

Merged
lukaszlenart merged 2 commits intoognl-3-4-xfrom
feature/port-root-preservation
Oct 26, 2025
Merged

Port changes from #449 about root preservation#461
lukaszlenart merged 2 commits intoognl-3-4-xfrom
feature/port-root-preservation

Conversation

@lukaszlenart
Copy link
Copy Markdown
Collaborator

@lukaszlenart lukaszlenart commented Oct 26, 2025

See detailed information in PR #449 which addresses issue #390

Closes #459

Fixes issue where addDefaultContext() unconditionally overwrites the
context root, breaking expressions that reference #root during list
processing operations (selection, projection, etc.).

The fix preserves the original root when:
- Context exists with a non-null root
- Context has user-defined variables (size() > 0)
- A different root is being set (nested evaluation)

This allows #root to correctly reference the original context object
during list operations while still supporting legitimate context reuse
with different roots (when size() == 0).

Note: context.size() only counts user-defined variables, not built-in
reserved keys like #root, #this, and _traceEvaluations.

Fixes #390
Adds test cases covering various scenarios where context root should
be preserved during nested evaluations:

- List selection with #root references
- List projection with #root references
- Lambda expressions accessing #root
- Context variable access during list processing
- Verification that root is not overwritten by list items

These tests ensure issue #390 is properly resolved and prevent
regression in future changes.

Related to #390
@lukaszlenart lukaszlenart marked this pull request as ready for review October 26, 2025 06:02
@sonarqubecloud
Copy link
Copy Markdown

@lukaszlenart lukaszlenart merged commit d5d9d8f into ognl-3-4-x Oct 26, 2025
5 checks passed
@lukaszlenart lukaszlenart deleted the feature/port-root-preservation branch October 26, 2025 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant