SYaoJun commented on code in PR #750:
URL: https://github.com/apache/geaflow/pull/750#discussion_r2870442456
##########
geaflow/geaflow-plugins/geaflow-store/geaflow-store-vector/src/main/java/org/apache/geaflow/store/lucene/GraphVectorIndex.java:
##########
@@ -166,11 +167,17 @@ public K searchVectorIndex(boolean isVertex, String
fieldName, float[] vector, i
throw new IllegalArgumentException("Unsupported key type: " +
keyClass.getName());
}
- reader.close();
-
return result;
} catch (IOException e) {
throw new RuntimeException("Failed to search vector index", e);
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to close IndexReader",
e);
Review Comment:
> 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]