Skip to content

fix: improve error handling in searchVectorIndex method#750

Open
SYaoJun wants to merge 2 commits intoapache:masterfrom
SYaoJun:228_fix_resources
Open

fix: improve error handling in searchVectorIndex method#750
SYaoJun wants to merge 2 commits intoapache:masterfrom
SYaoJun:228_fix_resources

Conversation

@SYaoJun
Copy link
Contributor

@SYaoJun SYaoJun commented Feb 28, 2026

ensure IndexReader is closed properly

What changes were proposed in this pull request?

How was this PR tested?

  • Tests have Added for the changes
  • Production environment verified
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.

A minor comment may need adjustment. Could you please take a look when you have time? Thanks!

try {
reader.close();
} catch (IOException e) {
throw new RuntimeException("Failed to close IndexReader", e);
Copy link
Contributor

Choose a reason for hiding this comment

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

With this change, the exception from reader.close() could mask the original exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With this change, the exception from reader.close() could mask the original exception.

Thanks for the suggestions. Refactored resource management to use try-with-resources, eliminating the risk of suppressed exceptions during IndexReader closure.

@SYaoJun SYaoJun requested a review from Leomrlin March 2, 2026 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants