Repository navigation
Conversation
This branch has not been deployed
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.
AbstractSequenceAggregationconverts a negative target index withrealIndex = size + targetIndexand then checksrealIndex > 0.realIndex == 0is the first element, so it is rejected by mistake:JsonPath.read("[42]", "$.last()")throws instead of returning42;JsonPath.read("[1,2,3]", "$.index(-3)")throws instead of returning1.This changes the check to
realIndex >= 0. An index before the start (for example$.index(-4)on a 3-element array) still throws the same exception with the same message.Tests (
SequenceBoundaryTest, 3 tests):last()on a one-element array,index(-3)selecting the first element, andindex(-4)still failing. The first two fail without the fix.Verification: with JDK 17 (Corretto 17.0.21) and Gradle 8.5, the
json-pathmodule tests passed (933 tests, 0 failures, 0 errors, 2 skipped) with the fix, and the same run reverted to the old check shows the failing cases../gradlew buildalso finished successfully. A full clean build of every module on other JDKs/OSes and CI were not run.Related open PRs #1079, #1081 and #1084 change negative index handling for set/delete/map, bounded slices and deep scan; this PR touches only the sequence function code path.