Gyeongtae Park created ZEPPELIN-6192: ----------------------------------------
Summary: Improve safety of getHit() method in ActionResponse and enhance interface documentation Key: ZEPPELIN-6192 URL: https://issues.apache.org/jira/browse/ZEPPELIN-6192 Project: Zeppelin Issue Type: Task Reporter: Gyeongtae Park Assignee: Gyeongtae Park Fix For: 1.0.0, 0.13.0 ### Summary Improved the robustness and readability of the Elasticsearch interpreter client layer. ### Changes - Replaced `ActionResponse#getHit()` implementation with a safer version that throws a `NoSuchElementException` if no hits are available. - Added a new method `getFirstHit()` that returns an `Optional<HitWrapper>` for callers that prefer to handle absence gracefully. - Updated Javadoc comments in both `ActionResponse.java` and `ElasticsearchClient.java` to provide clearer guidance on usage and behavior. ### Motivation The previous implementation of `getHit()` used `hits.get(0)` directly, which could lead to `IndexOutOfBoundsException` when no search results were present. This change introduces explicit failure behavior (`NoSuchElementException`) and provides a more modern, safer alternative via `Optional`. The enhanced Javadoc improves usability and reduces ambiguity for future maintainers and contributors. ### Affected Modules - zeppelin-elasticsearch -- This message was sent by Atlassian Jira (v8.20.10#820010)