Elasticsearch version (bin/elasticsearch --version):
~
Version: 8.0.0-SNAPSHOT, Build: default/tar/ed20d7c/2019-02-25T08:50:10.599708Z, JVM: 11.0.1
~
Plugins installed: none
JVM version (java -version):
~
java 11.0.1 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)
~
OS version (uname -a if on a Unix-like system):
~
Darwin castrovel.local 16.7.0 Darwin Kernel Version 16.7.0: Sun Oct 28 22:30:19 PDT 2018; root:xnu-3789.73.27~1/RELEASE_X86_64 x86_64
~
Description of the problem including expected versus actual behavior:
When the Elasticsearch Keystore is invoked with -x, and the stdin stream is closed with zero bytes, the tool crashes with an NPE in its stacktrace.
Steps to reproduce:
~
╭─{ yaauie@castrovel:~/src/elastic/logstash/build/elasticsearch (✘ master) }
╰─● printf '' | bin/elasticsearch-keystore add foo -f -x
Exception in thread "main" java.lang.NullPointerException
at org.elasticsearch.common.settings.AddStringKeyStoreCommand.execute(AddStringKeyStoreCommand.java:87)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:77)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
at org.elasticsearch.cli.Command.main(Command.java:90)
at org.elasticsearch.common.settings.KeyStoreCli.main(KeyStoreCli.java:40)
[error: 1]
~
Pinging @elastic/es-core-infra
I can verify. We probably need to guard aganist this as readLine()
stdinReader.readLine().toCharArray();
can return null.
This looks rather contained, I'll raise a PR soon
Most helpful comment
I can verify. We probably need to guard aganist this as
readLine()can return
null.This looks rather contained, I'll raise a PR soon