Details
Description
According to the API documentation for WhoisClient and FTPClient these commands appear to support inherited functionality of addProtocolCommandListener.
However, when i used this as follows....i get exceptions raised for TelnetClient and WhoisClient but not the FTPClient.
Is this a bug or as designed? Or am I missing something ?
import org.apache.commons.net.*;
import org.apache.commons.net.ProtocolCommandListener;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.telnet.TelnetClient;
import org.apache.commons.net.whois.WhoisClient;
import java.io.PrintWriter;
public class WhoisExample
{
public static void main(String args[])
{
try
catch(Exception e)
{ System.out.println("whois client exception" + e); }try
{ TelnetClient telnetClient = new TelnetClient(); telnetClient.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out))); }catch(Exception e)
{ System.out.println("telnet client exception" + e); }try
{ FTPClient ftpClient = new FTPClient(); ftpClient.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out))); System.out.println("no ftp client exception here !"); }catch(Exception e)
{ System.out.println("ftp client exception" + e); } }
}
I get the following exception....
Caught: java.lang.NullPointerException Disconnected from the target VM, address: '127.0.0.1:3140', transport: 'socket' java.lang.NullPointerException at org.apache.commons.net.SocketClient.addProtocolCommandListener(SocketClient.java:772) at org.apache.commons.net.SocketClient$addProtocolCommandListener.call(Unknown Source)