fix: maintain input order in categoryFinder.getByNames and tagFinder.getByNames#9882
Conversation
|
|
Agent-Logs-Url: https://github.com/halo-dev/halo/sessions/7d0cc8ed-53fe-4756-a248-03f6f484ecab Co-authored-by: ruibaby <21301288+ruibaby@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Agent-Logs-Url: https://github.com/halo-dev/halo/sessions/7d0cc8ed-53fe-4756-a248-03f6f484ecab Co-authored-by: ruibaby <21301288+ruibaby@users.noreply.github.com>
|
New changes are detected. LGTM label has been removed. |
|
getByNamesin bothCategoryFinderImplandTagFinderImplreturned results sorted by the store's default sort (priority/creationTimestamp/name) rather than preserving the caller-providednamesorder.Changes:
Queries.in(...), collect results and re-sort using a pre-builtHashMap<name → index>derived from the input collection — O(n log n), avoids repeatedindexOfscansCategoryFinderImpl.getByNamesandTagFinderImpl.getByNamesCategoryFinderImplTestandTagFinderImplTestverifying order is preserved when the store returns items in a different order than requestedWhat type of PR is this?
/kind bug
What this PR does / why we need it:
getByNamesinCategoryFinderImplandTagFinderImplignored the order of the inputnamescollection, returning results sorted by the store's default comparator instead. This fix post-sorts results using a name→index map built from the input, preserving caller-specified order.Which issue(s) this PR fixes:
Special notes for your reviewer:
The same bug existed in
TagFinderImpl.getByNamesand is fixed in the same commit.Does this PR introduce a user-facing change?
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
checkstyle.org/opt/hostedtoolcache/CodeQL/2.25.1/x64/codeql/tools/linux64/java/bin/java /opt/hostedtoolcache/CodeQL/2.25.1/x64/codeql/tools/linux64/java/bin/java -jar /opt/hostedtoolcache/CodeQL/2.25.1/x64/codeql/xml/tools/xml-extractor.jar --fileList=/tmp/codeql-scratch-dd1d0a2b113c8104/dbs/java/working/files-to-index12714299948922818648.list --sourceArchiveDir=/tmp/codeql-scratch-dd1d0a2b113c8104/dbs/java/src --outputDir=/tmp/codeql-scratch-dd1d0a2b113c8104/dbs/java/trap/java(dns block)If you need me to access, download, or install something from one of these locations, you can either: