TEDEFO-5169: Let the caller choose how much a joined path is simplified - #62
Merged
Merged
Conversation
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.
Fixes TEDEFO-5169.
The problem
XPathProcessor.joinshortens the path it produces: where a step is immediately followed by a step going back up, it removes both, soa/b/../cbecomesa/c.That shortening does not preserve meaning. The long form selects nothing when
bis absent from the document; the short form selectscregardless:The only caller is the EFX context override,
context::field, which means the value of the field by a path that starts at the context. Where the context is not present in the notice there is no starting point, so there should be no value — and the shortening removes exactly that. Until now the library made that decision on the caller's behalf, and silently.TEDEFO-5148 made the shortening stop at a step carrying a predicate, so the predicate would not be discarded with it. That left the behaviour uneven: the condition survives where the path happens to carry a predicate — which may come from
fields.jsonrather than from anything an author wrote — and is lost where it does not.What changed
The decision moves to the caller.
NONEPRESERVE_PREDICATESFULLa/b../ca/b/../ca/ca/ca/b[x]../ca/b[x]/../ca/b[x]/../ca/ca..[x]/ba/..[x]/ba/..[x]/bba/b../../ca/b/../../ccca[x]/b../ca[x]/b/../ca[x]/ca[x]/cjoin(first, second)delegates withPRESERVE_PREDICATES, so every existing caller behaves exactly as it does in 1.8.0. A missing setting is refused rather than falling into a default, since the setting decides how much of what the two paths said survives.The javadoc now states plainly that simplifying is not meaning-preserving, and each enum value documents what it gives up. That was missing before, which is why a context override could lose its anchor with nobody noticing.
Predicates on steps that are not cancelled are preserved under every setting. That was the original defect in TEDEFO-5148 and is unaffected by this choice.
Verification
FULLreproduces 1.7.0's cancellation exactly. Checked against a clean build of the 1.7.0 tag over sixteen cases: the only differences are where 1.7.0 was itself wrong — a predicate lost from a step that was never cancelled, a lost leading separator, a stray leading slash — each of them a defect TEDEFO-5148 fixed.mvn clean installpasses with the binary compatibility gate active, 90 tests. The delta is additive: one new enum, one new overload, no existing signature or behaviour altered, so this is a minor release.Impact
No SDK content is affected. Context overrides are not used in any released SDK — every occurrence of
::in 1.13.3, 1.14.2, 1.15.1, 1.16.0-beta.2 and 2.0.0-alpha.3 is theprecedingaxis. Nothing the SDK ships transpiles differently.Next
release/1.9.0: rewriteCHANGELOG.mdfor 1.9.0, documentingSimplification, and set the version.Simplification.NONEfor context overrides, and moves its dependency from1.9.0-SNAPSHOTto1.9.0.