Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8022580

sun.net.ftp.impl.FtpClient.nameList(String path) handles "null" incorrectly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P5 P5
    • 9
    • 7, 7u25, 8
    • core-libs
    • b129
    • windows_7

        FULL PRODUCT VERSION :


        A DESCRIPTION OF THE PROBLEM :
        This is the original source code of the method sun.net.ftp.impl.FtpClient#nameList():

            /**
             * Issues a NLST path command to server to get the specified directory
             * content. It differs from {@link #list(String)} method by the fact that
             * it will only list the file names which would make the parsing of the
             * somewhat easier.
             *
             * {@link #completePending()} <b>has</b> to be called once the application
             * is finished writing to the stream.
             *
             * @param path a <code>String</code> containing the pathname of the
             * directory to list or <code>null</code> for the current working
             * directory.
             * @return the <code>InputStream</code> from the resulting data connection
             * @throws IOException if an error occurs during the transmission.
             */
            public InputStream nameList(String path) throws sun.net.ftp.FtpProtocolException, IOException {
                Socket s;
                s = openDataConnection( " NLST " + path);
                if (s != null) {
                    return createInputStream(s.getInputStream());
                }
                return null;
            }

        As can be seen, there is no handling of a null as the path parameter in this code at all (although documented).
        A null as path doesn't lead to the expected result.




        REPRODUCIBILITY :
        This bug can be reproduced always.

        CUSTOMER SUBMITTED WORKAROUND :
        Passing an empty String instead of a null as the method argument.

              snikandrova Svetlana Nikandrova (Inactive)
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: