Protect against null pointer for BaseCommand

Subclasses of BaseCommand may not initialize argv field (e.g.
ScpCommand).
Recent change [1] uses argv field which may result in NPE.

This change will guard the code from such error.

[1]: https://gerrit-review.googlesource.com/c/gerrit/+/146191

Change-Id: I6dd3afa08fd696d25741b5bdec8530deac422261
Signed-off-by: Ardo Septama <aseptama@gmail.com>
This commit is contained in:
Ardo Septama 2018-01-29 11:44:17 +01:00
parent 5adfe0610f
commit dfa74b835f

View File

@ -414,6 +414,9 @@ public abstract class BaseCommand implements Command {
}
private void maskSensitiveParameters() {
if (argv == null) {
return;
}
sensitiveParameters = cache.get(this.getClass());
maskedArgv = new ArrayList<>();
maskedArgv.add(commandName);