DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=32034>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=32034
UnixFTPEntryParser.java fails to properly set MILLISECONDS field on FTPFile
Summary: UnixFTPEntryParser.java fails to properly set
MILLISECONDS field on FTPFile
Product: Commons
Version: 1.0 Alpha
Platform: All
URL: http://cvs.apache.org/viewcvs.cgi/jakarta-
commons/net/src/java/org/apache/commons/net/ftp/parser/U
nixFTPEntryParser.java?rev=1.19&view=markup
OS/Version: Other
Status: NEW
Severity: Normal
Priority: Other
Component: Net
AssignedTo: commons-dev@jakarta.apache.org
ReportedBy: jdunn@nm.cbc.ca
[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);
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
|