Skip to content

fix:Add check for empty search results to prevent array out of bounds#769

Merged
Leomrlin merged 1 commit intoapache:masterfrom
SYaoJun:0306_index_0
Mar 19, 2026
Merged

fix:Add check for empty search results to prevent array out of bounds#769
Leomrlin merged 1 commit intoapache:masterfrom
SYaoJun:0306_index_0

Conversation

@SYaoJun
Copy link
Contributor

@SYaoJun SYaoJun commented Mar 6, 2026

What changes were proposed in this pull request?

Directly accessing index 0 carries a risk.
It is better to check that the length is greater than zero in advance.

Document firstDoc = searcher.doc(topDocs.scoreDocs[0].doc);

How was this PR tested?

  • Tests have Added for the changes
  • Production environment verified

@Leomrlin Leomrlin requested a review from tanghaodong25 March 9, 2026 02:27
Copy link
Contributor

@Leomrlin Leomrlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Leomrlin
Copy link
Contributor

It looks like this PR might be conflicting with the one your just merged recently. Could you take a look and fix it when you have a moment? @SYaoJun

@Leomrlin Leomrlin merged commit 7cb33d9 into apache:master Mar 19, 2026
1 check passed
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.

2 participants