From 42ebfe7bdb6e2ad17cc57be85ae8a86fc3d9c2b2 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Fri, 6 Jan 2017 09:11:07 -0800 Subject: [PATCH] fix NPE --- .../java/org/elasticsearch/bootstrap/Bootstrap.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java b/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java index 2178d10e501..3d1e11869a7 100644 --- a/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java +++ b/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java @@ -242,15 +242,17 @@ final class Bootstrap { return keystore; } - private static Environment initialEnvironment(boolean foreground, Path pidFile, - KeyStoreWrapper keystore, Settings initialSettings) { + private static Environment createEnvironment(boolean foreground, Path pidFile, + KeyStoreWrapper keystore, Settings initialSettings) { Terminal terminal = foreground ? Terminal.DEFAULT : null; Settings.Builder builder = Settings.builder(); if (pidFile != null) { builder.put(Environment.PIDFILE_SETTING.getKey(), pidFile); } builder.put(initialSettings); - builder.setKeyStore(keystore); + if (keystore != null) { + builder.setKeyStore(keystore); + } return InternalSettingsPreparer.prepareEnvironment(builder.build(), terminal, Collections.emptyMap()); } @@ -292,7 +294,7 @@ final class Bootstrap { INSTANCE = new Bootstrap(); final KeyStoreWrapper keystore = loadKeyStore(initialEnv); - Environment environment = initialEnvironment(foreground, pidFile, keystore, initialEnv.settings()); + Environment environment = createEnvironment(foreground, pidFile, keystore, initialEnv.settings()); try { LogConfigurator.configure(environment); } catch (IOException e) {