Skip to content

Commit 42ebfe7

Browse files
committed
fix NPE
1 parent eb596d7 commit 42ebfe7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,17 @@ private static KeyStoreWrapper loadKeyStore(Environment initialEnv) throws Boots
242242
return keystore;
243243
}
244244

245-
private static Environment initialEnvironment(boolean foreground, Path pidFile,
246-
KeyStoreWrapper keystore, Settings initialSettings) {
245+
private static Environment createEnvironment(boolean foreground, Path pidFile,
246+
KeyStoreWrapper keystore, Settings initialSettings) {
247247
Terminal terminal = foreground ? Terminal.DEFAULT : null;
248248
Settings.Builder builder = Settings.builder();
249249
if (pidFile != null) {
250250
builder.put(Environment.PIDFILE_SETTING.getKey(), pidFile);
251251
}
252252
builder.put(initialSettings);
253-
builder.setKeyStore(keystore);
253+
if (keystore != null) {
254+
builder.setKeyStore(keystore);
255+
}
254256
return InternalSettingsPreparer.prepareEnvironment(builder.build(), terminal, Collections.emptyMap());
255257
}
256258

@@ -292,7 +294,7 @@ static void init(
292294
INSTANCE = new Bootstrap();
293295

294296
final KeyStoreWrapper keystore = loadKeyStore(initialEnv);
295-
Environment environment = initialEnvironment(foreground, pidFile, keystore, initialEnv.settings());
297+
Environment environment = createEnvironment(foreground, pidFile, keystore, initialEnv.settings());
296298
try {
297299
LogConfigurator.configure(environment);
298300
} catch (IOException e) {

0 commit comments

Comments
 (0)