commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 32623] New: - FTP component: FTPFile does not initialize miliseconds correctly
Date Fri, 10 Dec 2004 00:39:18 GMT
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=32623>.
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=32623

           Summary: FTP component: FTPFile does not initialize miliseconds
                    correctly
           Product: Commons
           Version: 1.2 Final
          Platform: PC
        OS/Version: Windows 2000
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Net
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: davidparks21@yahoo.com


Hi, I have been working with the FTP utilities and was saving the filename and 
lastModifiedTime (as taken from FTPFile.lastModifiedTime()) and had a problem 
where I would query a directory, save those two parameters for each of the 
files, then later on query the same directory (which in my test case has not 
changed any) and I would find that the FTPFile.lastModifiedTime() objects did 
not match. 

In looking furthur into it I found that the calendar objects returned by this 
function were off by a some random number of milliseconds, however it looked 
like the hour, minutes, and all other times of the calendar were correct, it 
was only the milliseconds.

Drilling furthur into the source code for the Commons FTP components I think I 
see what was overlooked to cause this condition.

In version 1.2.2 if you look at the UnixFTPEntryParser.java source (I believe 
this is the parser being used for my WSFTP server I am running, you can 
download this ftp server from download.com, I am using this for my development 
environment), looking on line 185 you have the following code:

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

I see that you are initially creating a new calendar instance, which, by 
default sets the calendar to the current time. Then you update the seconds, 
minutes, and hour of dat, however you are not initializing the miliseconds, 
hence the miliseconds vary between different instantiations of the same ftp 
entry.  This causes the Calendar.equals() function to indicate that the two 
times are different, though they should be equal.

If you add:
            cal.set(Calendar.MILLISECOND, 0);

I think you eliminate this problem.

Best regards,
David

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message