From 2ef4b3a7c9130ebc73a6ea8a2e35e8e546ed5529 Mon Sep 17 00:00:00 2001 From: ZP-AlwaysWin Date: Thu, 19 Sep 2019 23:38:25 +0800 Subject: [PATCH] Preventing null pointer exceptions --- .../main/java/io/k8s/cassandra/KubernetesSeedProvider.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cassandra/java/src/main/java/io/k8s/cassandra/KubernetesSeedProvider.java b/cassandra/java/src/main/java/io/k8s/cassandra/KubernetesSeedProvider.java index 9bba4e0d1..72751af5e 100644 --- a/cassandra/java/src/main/java/io/k8s/cassandra/KubernetesSeedProvider.java +++ b/cassandra/java/src/main/java/io/k8s/cassandra/KubernetesSeedProvider.java @@ -67,7 +67,8 @@ public List getSeeds() { String namespace = getEnvOrDefault("POD_NAMESPACE", "default"); String initialSeeds = getEnvOrDefault("CASSANDRA_SEEDS", ""); - if (initialSeeds.equals("")) { + + if ("".equals(initialSeeds)) { initialSeeds = getEnvOrDefault("POD_IP", ""); } @@ -79,11 +80,11 @@ public List getSeeds() { try { Endpoints endpoints = mapper.readValue(data, Endpoints.class); - logger.info("cassandra seeds: " + endpoints.ips.toString()); + logger.info("cassandra seeds: {}", endpoints.ips.toString()); return Collections.unmodifiableList(endpoints.ips); } catch (IOException e) { // This should not happen - logger.error("unexpected error building cassandra seeds: " + e.getMessage()); + logger.error("unexpected error building cassandra seeds: {}" , e.getMessage()); return Collections.emptyList(); } }