Skip to content

Commit

Permalink
[FLINK-11235][es] Close transportclient if no connection could be est…
Browse files Browse the repository at this point in the history
…ablished
  • Loading branch information
lamberken authored and zentol committed Jan 2, 2019
1 parent 7bb63f6 commit 4febcdc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.flink.streaming.connectors.elasticsearch.ElasticsearchApiCallBridge;
import org.apache.flink.streaming.connectors.elasticsearch.ElasticsearchSinkBase;
import org.apache.flink.streaming.connectors.elasticsearch.util.ElasticsearchUtils;
import org.apache.flink.util.IOUtils;
import org.apache.flink.util.Preconditions;

import org.elasticsearch.action.bulk.BackoffPolicy;
Expand Down Expand Up @@ -72,6 +73,10 @@ public TransportClient createClient(Map<String, String> clientConfig) {

// verify that we actually are connected to a cluster
if (transportClient.connectedNodes().isEmpty()) {

// close the transportClient here
IOUtils.closeQuietly(transportClient);

throw new RuntimeException("Elasticsearch client is not connected to any Elasticsearch nodes!");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.flink.streaming.connectors.elasticsearch.ElasticsearchApiCallBridge;
import org.apache.flink.streaming.connectors.elasticsearch.ElasticsearchSinkBase;
import org.apache.flink.streaming.connectors.elasticsearch.util.ElasticsearchUtils;
import org.apache.flink.util.IOUtils;
import org.apache.flink.util.Preconditions;

import org.elasticsearch.action.bulk.BackoffPolicy;
Expand Down Expand Up @@ -78,6 +79,10 @@ public TransportClient createClient(Map<String, String> clientConfig) {

// verify that we actually are connected to a cluster
if (transportClient.connectedNodes().isEmpty()) {

// close the transportClient here
IOUtils.closeQuietly(transportClient);

throw new RuntimeException("Elasticsearch client is not connected to any Elasticsearch nodes!");
}

Expand Down

0 comments on commit 4febcdc

Please sign in to comment.