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

FTPClient.listFiles() returns null for entries with space in group name

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Cannot Reproduce
    • 1.4
    • 2.0
    • None
    • None
    • Windows FTP server

    Description

      FTPClient fails parsing file list if the group name contains spaces, for example "Domain users" in Windows. The following patch helps:

      — commons-net-1.4.1/src/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImpl.java Sat Dec 3 19:05:48 2005
      +++ /u/ndv/sns_commons_io/src/org/apache/commons/net/ftp/parser/FTPTimestampParserImpl.java Sat Sep 2 16:47:03 2006
      @@ -21,6 +21,7 @@
      import java.text.SimpleDateFormat;
      import java.util.Calendar;
      import java.util.Date;
      +import java.util.Locale;
      import java.util.TimeZone;

      import org.apache.commons.net.ftp.Configurable;
      @@ -98,9 +99,16 @@
      if (parsed != null && pp.getIndex() == timestampStr.length())

      { working.setTime(parsed); }

      else {

      • throw new ParseException(
      • "Timestamp could not be parsed with older or recent DateFormat",
      • pp.getIndex());
        + // H4cK3D by mAXm
        + SimpleDateFormat dmy = new SimpleDateFormat("d MMM yyyy");
        + SimpleDateFormat dmh = new SimpleDateFormat("d MMM HH:ss");
        +
        + try { + working.setTime(dmh.parse(timestampStr)); + working.set(Calendar.YEAR, Calendar.getInstance().get(Calendar.YEAR)); + }

        catch (ParseException ex)

        { + working.setTime(dmy.parse(timestampStr)); + }

        }
        }
        return working;

      Attachments

        Activity

          People

            Unassigned Unassigned
            ndv Dmitry Negoda
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: