zeppelin icon indicating copy to clipboard operation
zeppelin copied to clipboard

[ZEPPELIN-6192] Enhance getHit() safety in ActionResponse and improve interface documentation

Open ParkGyeongTae opened this issue 6 months ago • 0 comments

What is this PR for?

This PR improves the robustness and clarity of the Elasticsearch interpreter module in Zeppelin.

  • Reimplemented ActionResponse#getHit() to throw NoSuchElementException instead of relying on unchecked access to the first hit.
  • Introduced a new method getFirstHit() which returns an Optional<HitWrapper> for safer optional access.
  • Added and refined Javadoc comments in:
    • ActionResponse.java for both getHit() and getFirstHit()
    • ElasticsearchClient.java to improve clarity on interface usage

What type of PR is it?

Documentation Refactoring

Todos

  • [x] Refactor getHit() to throw a safe exception
  • [x] Add getFirstHit() method using Optional

What is the Jira issue?

  • https://issues.apache.org/jira/browse/ZEPPELIN/ZEPPELIN-6192

How should this be tested?

  • Build Test
  • Elasticsearch Interpreter Test

Screenshots (if appropriate)

Questions:

  • Does the license files need to update? No.
  • Is there breaking changes for older versions? No.
  • Does this needs documentation? No.

ParkGyeongTae avatar Jun 06 '25 10:06 ParkGyeongTae