Skip to content

Fix Issue #472: Revert PR #204 to restore root context preservation in lambda expressions#476

Merged
lukaszlenart merged 1 commit intoognl-3-4-xfrom
fix/issue-472-root-context
Nov 1, 2025
Merged

Fix Issue #472: Revert PR #204 to restore root context preservation in lambda expressions#476
lukaszlenart merged 1 commit intoognl-3-4-xfrom
fix/issue-472-root-context

Conversation

@lukaszlenart
Copy link
Copy Markdown
Collaborator

Summary

This PR fixes Issue #472 where lambda expressions in list operations (selection, projection) cannot access root context properties.

Root Cause: PR #204 introduced addDefaultContext(root, context) in Ognl.getValue() which overwrote the context root with the current evaluation target (e.g., list items), making original root properties inaccessible via #root references.

Solution: Complete revert to pre-PR #204 behavior:

  • Removed addDefaultContext() wrapper in Ognl.getValue() - context now passed through directly preserving original root
  • Removed short-circuit optimization from ASTChain.getValueBody() - null property access now throws OgnlException as before
  • Updated existing tests (ChainTest, NullRootTest) to expect exceptions instead of null returns
  • Added comprehensive Issue472CustomMethodAccessorTest with 5 test cases validating root preservation

Breaking Change: Accessing properties on null now throws OgnlException instead of returning null (reverts to original OGNL behavior).

Test Plan

  • All 947 existing tests pass
  • New Issue472CustomMethodAccessorTest verifies:
    • List selection can access root properties via #root.property
    • List projection can access root properties via #root.property
    • Multiple root properties accessible in single expression
    • Both #root and #this work correctly in lambda expressions
    • Empty results when root property doesn't match
  • Updated ChainTest.shouldShortCircuitAccessingNullChild expects OgnlException
  • Updated all NullRootTest tests expect OgnlException with correct error messages
  • Verified Java 8 compatibility

Verified with: mvn clean test - 947 tests passing, 0 failures, 0 errors

Fixes #472

🤖 Generated with Claude Code

…ervation in lambda expressions

This commit reverts changes introduced in PR #204 (short-circuit optimization) to fix Issue #472
where lambda expressions in list operations could not access root context properties.

Changes:
- Removed addDefaultContext() wrapper in Ognl.getValue() that was overwriting context root
- Removed short-circuit optimization logic from ASTChain.getValueBody()
- Reverted to pre-PR #204 behavior: null property access now throws OgnlException
- Updated ChainTest and NullRootTest to expect exceptions instead of null returns
- Added comprehensive Issue472CustomMethodAccessorTest with 5 test cases

The revert simplifies the codebase and ensures context root preservation throughout
nested evaluations, allowing #root references to work correctly in lambda expressions.

Fixes #472

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Nov 1, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
D Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@lukaszlenart lukaszlenart merged commit 043a716 into ognl-3-4-x Nov 1, 2025
4 of 5 checks passed
@lukaszlenart lukaszlenart deleted the fix/issue-472-root-context branch November 1, 2025 18:08
@lukaszlenart lukaszlenart added this to the 3.4.9 milestone Nov 4, 2025
lukaszlenart added a commit that referenced this pull request Nov 4, 2025
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
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 7, 2025
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 7, 2025
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 7, 2025
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]>
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.

1 participant