Fix Issue #472: Preserve root context in nested evaluations (port from PR #476)#481
Closed
lukaszlenart wants to merge 1 commit intomainfrom
Closed
Fix Issue #472: Preserve root context in nested evaluations (port from PR #476)#481lukaszlenart wants to merge 1 commit intomainfrom
lukaszlenart wants to merge 1 commit intomainfrom
Conversation
Port fix from PR #476 (ognl-3-4-x) to main branch with adaptations for backward compatibility. Lambda expressions in list operations (selection, projection) can now access properties from the original context root via #root references. Root cause: Ognl.getValue() called context.withRoot(root) which overwrote the context root during nested evaluations (e.g., when processing list items), making original root properties inaccessible. Solution: Conditionally preserve original root by only calling withRoot() when context has no root, root matches existing root, or context is empty. This maintains backward compatibility while fixing #root access in lambdas. Changes: - Modified Ognl.getValue() to preserve root context during nested evaluations - Added Issue472CustomMethodAccessorTest with 5 comprehensive test cases - All 612 existing tests pass, maintaining backward compatibility - Short-circuit optimization preserved (not removed like in PR #476) Fixes #472 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
lukaszlenart
added a commit
that referenced
this pull request
Nov 4, 2025
Configure sonar.coverage.jacoco.xmlReportPaths property to point SonarCloud to the JaCoCo XML report location in the ognl module. This resolves the issue where SonarCloud was reporting 0% coverage despite tests running with coverage enabled. Fixes #481 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
3 tasks
lukaszlenart
added a commit
that referenced
this pull request
Nov 4, 2025
Configure sonar.coverage.jacoco.xmlReportPaths property to point SonarCloud to the JaCoCo XML report location in the ognl module. This resolves the issue where SonarCloud was reporting 0% coverage despite tests running with coverage enabled. Fixes #481 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
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.


Summary
Ports the fix from PR #476 (ognl-3-4-x branch) to the main branch with adaptations for backward compatibility. This fix resolves Issue #472 where lambda expressions in list operations (selection, projection) cannot access properties from the original context root via
#rootreferences.Root Cause
Ognl.getValue()unconditionally calledcontext.withRoot(root)which overwrote the context root during nested evaluations. When processing list items in lambda expressions, this caused#rootto reference the current list item instead of the original context root, making original root properties inaccessible.Solution
Implemented conditional root preservation logic that only updates the context root when:
This prevents nested evaluations from overwriting the original root while maintaining backward compatibility for existing use cases.
Changes
ognl/src/main/java/ognl/Ognl.java: Added smart conditional logic to preserve root context during nested evaluationsognl/src/test/java/ognl/test/Issue472CustomMethodAccessorTest.java: Comprehensive test suite with 5 test cases validating root preservationTest Coverage
New Issue472CustomMethodAccessorTest validates:
#root.property#rootand#thiswork correctly in lambda expressionsVerification
Differences from PR #476
Test Results
Fixes #472
🤖 Generated with Claude Code