Repository navigation
fix(clients): browseSynonyms pagination (CR-11727) - #6652
Merged
Merged
Conversation
Java `browseSynonyms` incremented an internal page counter but never wrote it back to the params, so every request re-fetched page 0. With a full first page (1000 synonyms) the stop condition was never reached: the iterator looped and returned duplicate hits until it ran out of memory. Mirror `browseRules` by writing the page back before each `searchSynonyms` call, and stop the no-arg overload from passing null params. While auditing the other clients, PHP had a related pagination bug: the Synonym and Rule iterators' stop-guard compared the cumulative key to the current page's hit count, so they stopped after the first full page and silently truncated results to hitsPerPage. Stop only on a non-full page instead. Add per-language regression tests (Java, PHP, JavaScript, Kotlin, Scala, Swift) that serve a full page 0 then a partial page 1 and assert the iterator requests pages 0 then 1, aggregates every hit exactly once, and terminates.
Contributor
π₯ Breaking changes detected !!Either this PR or a previous PR not released yet introduced breaking changes, be careful when merging. βοΈ Code generated!
π Benchmark resultsBenchmarks performed on the method using a mock server, the results might not reflect the real-world performance.
|
`List.of` is Java 9+, but the Java client targets Java 8 (the `client java@8` CI job failed). Replace it with `Arrays.asList`.
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.
What & why
π CR-11727
SearchClient.browseSynonyms(Java) incremented an internal page counter but never wrote it back to the request params, so every call re-requestedpage=0. With a full first page (β₯1000 synonyms) the stop condition never triggered β the iterator looped and returned duplicate hits until it ran out of memory. Fixed to write the page back before eachsearchSynonymscall (mirrorsbrowseRules); the no-arg overload no longer passesnull.While auditing the other clients I found a related bug in PHP:
SynonymIterator/RuleIteratorstopped after the first full page (the guard compared the cumulative key to the current page's hit count), silently truncating results tohitsPerPage. They now stop only on a non-full page, like every other client. JavaScript, Kotlin, Scala and Swift were already correct.Tests
Added a
browseSynonymspagination regression test in all six implementing languages (Java, PHP, JavaScript, Kotlin, Scala, Swift): serve a full page 0 then a partial page 1, and assert the client requests pages0 β 1, aggregates every hit exactly once, and terminates. All pass locally.Notes
jvmTest(the client's common test set has no coroutine runner).