You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/12/22 14:35:07 UTC

[commons-vfs] branch master updated: [VFS-813] NullPointerException needs a better message in SftpClientFactory when connect with private key.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git


The following commit(s) were added to refs/heads/master by this push:
     new d97d0f0  [VFS-813] NullPointerException needs a better message in SftpClientFactory when connect with private key.
d97d0f0 is described below

commit d97d0f08ae55ac5beef14c35e7ef0da4634c3cf7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Dec 22 09:35:03 2021 -0500

    [VFS-813] NullPointerException needs a better message in
    SftpClientFactory when connect with private key.
    
    Provide a message to the NPE when the username is null.
---
 .../java/org/apache/commons/vfs2/provider/sftp/SftpClientFactory.java | 2 ++
 src/changes/changes.xml                                               | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpClientFactory.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpClientFactory.java
index 6b0d646..2680d62 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpClientFactory.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpClientFactory.java
@@ -19,6 +19,7 @@ package org.apache.commons.vfs2.provider.sftp;
 import java.io.File;
 import java.io.IOException;
 import java.time.Duration;
+import java.util.Objects;
 import java.util.Properties;
 
 import org.apache.commons.lang3.SystemUtils;
@@ -135,6 +136,7 @@ public final class SftpClientFactory {
      */
     public static Session createConnection(final String hostname, final int port, final char[] username,
         final char[] password, final FileSystemOptions fileSystemOptions) throws FileSystemException {
+        Objects.requireNonNull(username, "username");
         final JSch jsch = new JSch();
 
         // new style - user passed
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 9352bd0..6460580 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -74,6 +74,10 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="fix" dev="ggregory" due-to="Gary Gregory">
         Fix OSGi "Unused Import-Package instructions".
       </action>
+      <action type="fix" issue="VFS-813" dev="ggregory" due-to="Andrey Turbanov, Gary Gregory">
+        NullPointerException needs a better message in SftpClientFactory when connect with private key.
+      </action>
+
       <!-- ADD -->
       <action type="add" dev="ggregory" due-to="Seth Falco">
         Add vscode files to gitignore #205.