From f1e03b5ed5b53dd909f0e20d8684113120cd73e5 Mon Sep 17 00:00:00 2001 From: Bryan Bende Date: Thu, 6 Dec 2018 11:45:26 -0500 Subject: [PATCH] NIFI-5877 Protecting against null values when obtaining master address Signed-off-by: Pierre Villard This closes #3206. --- .../nifi/hbase/HBase_1_1_2_ClientService.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientService.java b/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientService.java index 5d9047086f..050c8d0e3b 100644 --- a/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientService.java +++ b/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientService.java @@ -20,7 +20,9 @@ import org.apache.commons.lang3.StringUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.Cell; +import org.apache.hadoop.hbase.ClusterStatus; import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; @@ -65,7 +67,6 @@ import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; @@ -262,7 +263,16 @@ public class HBase_1_1_2_ClientService extends AbstractControllerService impleme final Admin admin = this.connection.getAdmin(); if (admin != null) { admin.listTableNames(); - masterAddress = admin.getClusterStatus().getMaster().getHostAndPort(); + + final ClusterStatus clusterStatus = admin.getClusterStatus(); + if (clusterStatus != null) { + final ServerName master = clusterStatus.getMaster(); + if (master != null) { + masterAddress = master.getHostAndPort(); + } else { + masterAddress = null; + } + } } } } @@ -323,8 +333,6 @@ public class HBase_1_1_2_ClientService extends AbstractControllerService impleme } - private String principal = null; - protected Configuration getConfigurationFromFiles(final String configFiles) { final Configuration hbaseConfig = HBaseConfiguration.create(); if (StringUtils.isNotBlank(configFiles)) { @@ -346,16 +354,6 @@ public class HBase_1_1_2_ClientService extends AbstractControllerService impleme } } - private static final byte[] EMPTY_VIS_STRING; - - static { - try { - EMPTY_VIS_STRING = "".getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } - private List buildPuts(byte[] rowKey, List columns) { List retVal = new ArrayList<>();