ssh: Remove redundant null check for home.getAbsoluteFile()

File#getAbsoluteFile is non-nullable, so this check can never trigger.
Worse, getAbsoluteFile can throw an exception such as
InvalidPathException, and since this call isn't in the "try" block
that checks for that, the exception would then escape the getSession
call.

Noticed because the exception is being thrown in googlesource.com's
custom SshdSessionFactory, causing incoming ssh requests to fail
(noticed using internal tests).

Change-Id: I57f2d5e497ff678b17573f79827b6e1d9a6c9b9f
Signed-off-by: Jonathan Nieder <jrn@google.com>
This commit is contained in:
Jonathan Nieder 2023-09-11 17:12:17 -07:00
parent 82c6638c72
commit 3bc1da30df
1 changed files with 1 additions and 1 deletions

View File

@ -244,7 +244,7 @@ public SshdSession getSession(URIish uri,
JGitSshClient.PREFERRED_AUTHENTICATIONS,
defaultAuths);
}
if (home != null && home.getAbsoluteFile() != null) {
if (home != null) {
try {
jgitClient.setAttribute(JGitSshClient.HOME_DIRECTORY,
home.getAbsoluteFile().toPath());