Mehmet Can Cömert created NET-742:
-------------------------------------

             Summary: NullPointerException when FTPClient remote verification 
fails and remote
                 Key: NET-742
                 URL: https://issues.apache.org/jira/browse/NET-742
             Project: Commons Net
          Issue Type: Bug
          Components: FTP
    Affects Versions: 3.11.1
            Reporter: Mehmet Can Cömert


If remoteHostVerification fails, commons-net tries to throw an Error Message:
 

{color:#000000} {color}{color:#3f7f5f}// Grab the host before we close the 
socket to avoid NET-663{color}

{color:#000000} {color}{color:#7f0055}final{color}{color:#000000} InetAddress 
{color}{color:#6a3e3e}socketHost{color}{color:#000000} = 
{color}{color:#6a3e3e}socket{color}{color:#000000}.getInetAddress();{color}

{color:#000000} 
{color}{color:#6a3e3e}socket{color}{color:#000000}.close();{color}

{color:#000000} {color}{color:#7f0055}throw{color}{color:#000000} 
{color}{color:#7f0055}new{color}{color:#000000} 
IOException({color}{color:#2a00ff}"Host attempting data connection 
"{color}{color:#000000} + 
{color}{color:#6a3e3e}socketHost{color}{color:#000000}.getHostAddress() + 
{color}{color:#2a00ff}" is not same as server "{color}{color:#000000} + 
getRemoteAddress().getHostAddress());{color}

 

 

However if the {color:#0066cc}getRemoteAddress{color}{color:#000000}() is NULL 
after closing the socket then we get again a NPE.
This is very similar to NET-663, but now the second parameter added into 
message is causing NPE. {color}

Here is the Stack Trace:
{code:java}
java.lang.NullPointerException: Cannot invoke 
"java.net.InetAddress.getHostAddress()" because the return value of 
"org.apache.commons.net.ftp.FTPClient.getRemoteAddress()" is null
        at 
org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:801)
        at 
org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:665)
        at 
org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:1990)
        at 
org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2087)
        at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2287)
        at 
org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2252){code}
Probably it would be fixed by
 # First prepare the message in a variable
 # Then close the socket.
 # Finally throw the Exception

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to