Fix NPE in TransportGitSsh.ExtSession.exec()

Bug: 527383
Change-Id: I965860b4e0e9aa1adf6a1bb0735940cbd22adced
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Matthias Sohn 2017-11-17 22:16:31 +01:00 committed by David Pursehouse
parent 809b9f8d5c
commit 29c5f49f63
1 changed files with 12 additions and 8 deletions

View File

@ -242,14 +242,7 @@ public Process exec(String command, int timeout)
args.add(getURI().getHost());
args.add(command);
ProcessBuilder pb = new ProcessBuilder();
pb.command(args);
File directory = local.getDirectory();
if (directory != null)
pb.environment().put(Constants.GIT_DIR_KEY,
directory.getPath());
ProcessBuilder pb = createProcess(args);
try {
return pb.start();
} catch (IOException err) {
@ -257,6 +250,17 @@ public Process exec(String command, int timeout)
}
}
private ProcessBuilder createProcess(List<String> args) {
ProcessBuilder pb = new ProcessBuilder();
pb.command(args);
File directory = local != null ? local.getDirectory() : null;
if (directory != null) {
pb.environment().put(Constants.GIT_DIR_KEY,
directory.getPath());
}
return pb;
}
@Override
public void disconnect() {
// Nothing to do