Skip to content

Preserve wildcard arguments when reusing compiled functions - #1088

Open
curforever wants to merge 1 commit into
json-path:masterfrom
curforever:fix/compiled-aggregation-wildcards
Open

curforever wants to merge 1 commit into
json-path:masterfrom
curforever:fix/compiled-aggregation-wildcards

Conversation

@curforever

Copy link
Copy Markdown

Fixes #1038.

Reusing JsonPath.compile("max($.dataset[*].value)") fails after the first read because FunctionPathToken removes the argument's first wildcard after every function invocation. That cleanup was introduced for #786, where Length temporarily appends a wildcard, but it also deletes wildcards supplied by callers of other functions.

Move that cleanup into Length and restore only the tail link that the current invocation changed, using finally so evaluation failures also restore it. Remove the generic wildcard deletion from FunctionPathToken. Existing wildcard arguments and repeated deep-scan length()/size() queries remain reusable; no public API changes.

Validation on Windows with Gradle 8.5:

  • The same final regression class runs 65 invocations across all eight test providers: 57 fail / 8 pass against the original production files; all 65 pass after the fix, without skips.
  • Coverage includes min/max/sum/avg/stddev, cached query reuse, length/size with existing wildcards, the deep-scan behavior from Different result for each invocation #786, and retry after a provider exception.
  • On both Java 17 and Java 21, the upstream CI steps build --warning-mode all, check, and clean publishToMavenLocal succeed. Each JDK's two-module suite has 1,078 passes, 13 existing skips, and no failures. The skipped test classes are unchanged from the base commit.

This targets sequential compiled-query reuse and temporary wildcard cleanup; it does not claim to make every compiled function thread-safe.

Move the cleanup of Length's temporary wildcard into its own finally block.
Removing the first wildcard after every function call otherwise changes a
compiled aggregation's original argument and breaks subsequent reads.

Add regression coverage across all eight test providers for numeric aggregation,
cached queries, repeated length/size calls, and recovery after provider failure.

Fixes json-path#1038.

This branch has not been deployed

No deployments
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.

Compiled JsonPath containing an aggregation function with [*] notation cannot be reused

1 participant