]> source.dussan.org Git - jgit.git/commitdiff
ssh: Remove redundant null check for home.getAbsoluteFile() 67/204267/1
authorJonathan Nieder <jrn@google.com>
Tue, 12 Sep 2023 00:12:17 +0000 (17:12 -0700)
committerJonathan Nieder <jrn@google.com>
Tue, 12 Sep 2023 00:12:17 +0000 (17:12 -0700)
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>
org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSessionFactory.java

index cb2549e900881293f4efd4ab194cc150a4d52819..2c3cbe55c9e80a7f7e7037763ca5e0c8b76402ed 100644 (file)
@@ -244,7 +244,7 @@ public class SshdSessionFactory extends SshSessionFactory implements Closeable {
                                                        JGitSshClient.PREFERRED_AUTHENTICATIONS,
                                                        defaultAuths);
                                }
-                               if (home != null && home.getAbsoluteFile() != null) {
+                               if (home != null) {
                                        try {
                                                jgitClient.setAttribute(JGitSshClient.HOME_DIRECTORY,
                                                                home.getAbsoluteFile().toPath());