Gyeongtae Park created ZEPPELIN-6262:
----------------------------------------
Summary: Refactor ElasticsearchClientTypeBuilder for safer enum
parsing and blank input handling
Key: ZEPPELIN-6262
URL: https://issues.apache.org/jira/browse/ZEPPELIN-6262
Project: Zeppelin
Issue Type: Improvement
Reporter: Gyeongtae Park
Assignee: Gyeongtae Park
Fix For: 1.0.0, 0.12.1, 0.13.0
The current implementation of {{ElasticsearchClientTypeBuilder}} performs a
two-step validation by checking for a matching enum value before calling
{{{}Enum.valueOf(){}}}. This can be simplified and made more robust by using
exception handling.
*Changes Made:*
* Replaced {{StringUtils.isEmpty()}} with {{StringUtils.isBlank()}} to
correctly treat whitespace-only strings as invalid input
* Removed redundant {{Arrays.stream(...).anyMatch(...)}} check and replaced it
with a {{try-catch}} around {{Enum.valueOf(...)}}
* Ensured that invalid or {{null}} inputs fall back to
{{ElasticsearchClientType.UNKNOWN}} safely
*Benefits:*
* Improved code readability and conciseness
* Reduced enum value lookup from two passes to one
* Better handling of edge cases like {{null}} or whitespace-only strings
--
This message was sent by Atlassian Jira
(v8.20.10#820010)