[ 
https://issues.apache.org/jira/browse/FLINK-30929?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17685029#comment-17685029
 ] 

Kenny Wu commented on FLINK-30929:
----------------------------------

[~martijnvisser] I have checked the latest version. The case has been improved 
already, as well as other property check statements.
{code:java}
public B setHosts(HttpHost... hosts) {
    Preconditions.checkNotNull(hosts);
    Preconditions.checkState(hosts.length > 0, "Hosts cannot be empty.");
    this.hosts = Arrays.asList(hosts);
    return this.self();
}{code}
 

> Add helpful message when ElasticsearchSink.Builder.build() throws an 
> IllegalArgumentException.
> ----------------------------------------------------------------------------------------------
>
>                 Key: FLINK-30929
>                 URL: https://issues.apache.org/jira/browse/FLINK-30929
>             Project: Flink
>          Issue Type: Improvement
>          Components: Connectors / ElasticSearch
>    Affects Versions: 1.13.6
>            Reporter: Kenny Wu
>            Priority: Major
>         Attachments: image-2023-02-06-21-28-37-835.png
>
>
> When I test flink-connector-elasticsearch on my project. And *I got an 
> IllegalArgumentException with nothing helpful message.* 
> *Here's the exception message:* 
>  
> {code:java}
> Exception in thread "main" java.lang.IllegalArgumentException
>     at 
> org.apache.flink.util.Preconditions.checkArgument(Preconditions.java:122)
>     at 
> org.apache.flink.streaming.connectors.elasticsearch7.Elasticsearch7ApiCallBridge.<init>(Elasticsearch7ApiCallBridge.java:61)
>     at 
> org.apache.flink.streaming.connectors.elasticsearch7.ElasticsearchSink.<init>(ElasticsearchSink.java:74)
>     ... {code}
>  
> *I could not see which exactly the argument was illegal.*
> After I read the code in (Elasticsearch7ApiCallBridge.java:61), I realized 
> that proberbly  the ES hosts was empty. And finally fixed it.
> !image-2023-02-06-21-28-37-835.png!
> I think helpful message should be printed when such an important argument is 
> illegal and fails to build the connector.
> And I'd love to improve it. thanks
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to