Skip to content

Commit

Permalink
Gh-2997: Fix NullPointerException in MiniAccumuloStore (#2998)
Browse files Browse the repository at this point in the history
* If the getProperties().getZookeepers() is null, rather than throwing a NullPointerException, set the zooKeeperPort to the zooKeeper default port.

---------

Co-authored-by: GCHQDeveloper314 <94527357+GCHQDeveloper314@users.noreply.github.com>
  • Loading branch information
Banji0x and GCHQDeveloper314 authored Jul 4, 2023
1 parent 62d8331 commit 23eb989
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 Crown Copyright
* Copyright 2020-2023 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -148,9 +148,10 @@ private void createCluster() throws IOException, InterruptedException {

MiniAccumuloConfig config = new MiniAccumuloConfig(getAccumuloDirectory(), rootUserPassword);

String[] zookeepers = getProperties().getZookeepers().split(":");
if (zookeepers.length == 2) {
config.setZooKeeperPort(Integer.parseInt(zookeepers[1]));
String zookeepers = getProperties().getZookeepers();
String[] zooKeepersArray = zookeepers != null ? zookeepers.split(":") : null;
if (zooKeepersArray != null && zooKeepersArray.length == 2) {
config.setZooKeeperPort(Integer.parseInt(zooKeepersArray[1]));
} else {
config.setZooKeeperPort(DEFAULT_ZOOKEEPER_PORT);
}
Expand Down

0 comments on commit 23eb989

Please sign in to comment.