From d7bc835053f622f095e6616465f29ddc605b8fc4 Mon Sep 17 00:00:00 2001 From: Cyrus Vafadari Date: Tue, 21 Jul 2020 15:34:04 -0700 Subject: [PATCH] Check for unexpected datatypes in response from server (#428) * Check for unexpected datatypes in response from server * Update src/main/java/io/confluent/connect/elasticsearch/jest/JestElasticsearchClient.java Co-authored-by: Lev Zemlyanov * fmt Co-authored-by: Lev Zemlyanov --- .../connect/elasticsearch/jest/JestElasticsearchClient.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/io/confluent/connect/elasticsearch/jest/JestElasticsearchClient.java b/src/main/java/io/confluent/connect/elasticsearch/jest/JestElasticsearchClient.java index 9db59e45a..7d5bdc64a 100644 --- a/src/main/java/io/confluent/connect/elasticsearch/jest/JestElasticsearchClient.java +++ b/src/main/java/io/confluent/connect/elasticsearch/jest/JestElasticsearchClient.java @@ -178,6 +178,11 @@ private Version getServerVersion() throws IOException { LOG.warn("Couldn't get Elasticsearch version, result is null"); return defaultVersion; } + if (!result.has("nodes")) { + LOG.warn("Couldn't get Elasticsearch version from result {} (result has no nodes). " + + "Assuming {}.", result, defaultVersion); + return defaultVersion; + } checkForError(result);