Issue Details (XML | Word | Printable)

Key: NET-69
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Julian C. Dunn
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Net

UnixFTPEntryParser.java fails to properly set MILLISECONDS field on FTPFile

Created: 03/Nov/04 08:24 AM   Updated: 20/Sep/07 05:31 AM
Return to search
Component/s: None
Affects Version/s: Nightly Builds
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments:
  Size
Text File UnixFTPEntryParser.java.patch 2004-11-03 08:25 AM Julian C. Dunn 0.4 kB
Environment:
Operating System: other
Platform: All

Bugzilla Id: 32034


 Description  « Hide
[This defect may affect other parsers too -- I haven't checked.]

On listings returned from UNIX FTP servers, only the hour and minute of the
modification time of a given FTPFile is shown. UnixFTPEntryParser.java does the
following when encountering such a listing:

Calendar cal = Calendar.getInstance();
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.HOUR_OF_DAY, 0);

try
{
int pos = MONTHS.indexOf(mo);
int month = pos / 4;

if (null != yr)

{ // it's a year cal.set(Calendar.YEAR, Integer.parseInt(yr)); }

else
{
// it must be hour/minute or we wouldn't have matched
int year = cal.get(Calendar.YEAR);
// if the month we're reading is greater than now, it must
// be last year
if (cal.get(Calendar.MONTH) < month)

{ year--; }

cal.set(Calendar.YEAR, year);
cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(hr));
cal.set(Calendar.MINUTE, Integer.parseInt(min));
}
cal.set(Calendar.MONTH, month);

cal.set(Calendar.DATE, Integer.parseInt(da));
file.setTimestamp(cal);

Unfortunately, the code does not properly set the MILLISECOND field of the
original Calendar object. This means the MILLISECOND field is dependent upon the
system time that the object is actually created. Therefore, the FTPFile's
timestamp is wrong.

I propose that the above code be patched to add a cal.set(Calendar.MILLISECOND, 0);



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Henri Yandell made changes - 16/May/06 09:47 AM
Field Original Value New Value
issue.field.bugzillaimportkey 32034 12341849
Henri Yandell made changes - 16/May/06 11:48 AM
Assignee Jakarta Commons Developers Mailing List [ commons-dev@jakarta.apache.org ]
Project Commons [ 12310458 ] Commons Net [ 12310487 ]
Key COM-1697 NET-69
Affects Version/s 1.0 Alpha [ 12311665 ]
Component/s Net [ 12311127 ]
Henri Yandell made changes - 16/May/06 12:18 PM
Affects Version/s 1.0 Alpha [ 12311775 ]
Henri Yandell made changes - 20/Sep/07 05:31 AM
Status Resolved [ 5 ] Closed [ 6 ]