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

Problem with private OutputStream __storeFileStream(int command, String remote) in org.apache.commons.net.ftp.FTPClient

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • None
    • None
    • None
    • Used a standalone to connect to Mainframes z/os system, later the code will be moved to unix box as part of web-project

    Description

      private OutputStream __storeFileStream(int command, String remote)
      throws IOException
      {
      Socket socket;
      if((socket = openDataConnection(command, remote)) == null)
      return null;
      OutputStream output = socket.getOutputStream();
      if(__fileType == 0)

      { output = new BufferedOutputStream(output, 1024); output = new ToNetASCIIOutputStream(output); }

      return new SocketOutputStream(socket, output);
      }

      This method in FTPClient.java is called by the method storeFileStream(String str). At line number 6 in the above mentioned method, it returns null when unable to open DataConnection which could be because of concurrent file access issues. In such cases instead of returning null, this method should throw an IOException like:

      Socket socket;
      if((socket = openDataConnection(command, remote)) == null) throw new IOException;

      As of now in my code i have used a null check to avoid this. However i could not understand why an outputstream creation method will return a null reference and not throw an IOException. It was hard to believe that I was getting null pointer exception while getting an output stream reference.

      Attachments

        Activity

          People

            Unassigned Unassigned
            swami.nandan Swami Nandan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: