Uploaded image for project: 'Commons Net'
  1. Commons Net
  2. NET-608

Exception when using addProtocolCommandListener with library org.apache.commons.net.telnet.TelnetClient

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Not A Problem
    • 3.5
    • None
    • Telnet
    • Windows 7, Java JDK 1.8,

    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

      { WhoisClient whoisClient = new WhoisClient(); whoisClient.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out))); }

      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)

      Attachments

        Activity

          People

            Unassigned Unassigned
            anthony.kearns Anthony Kearns
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: