RFR: 8255078: sun/net/ftp/imp/FtpClient$MLSxParser uses wrong datetime format [v2]

Igor Ignatyev iignatyev at openjdk.java.net
Fri Oct 23 17:29:58 UTC 2020


> Hi all,
> 
> could you please review this small patch?
> 
> according to [RFC3659](https://tools.ietf.org/html/rfc3659), time values in MLSx response have the following format: 
>>    time-val = 14DIGIT [ "." 1*DIGIT ] 
>> 
>>    The leading, mandatory, fourteen digits are to be interpreted as, in 
>>    order from the leftmost, four digits giving the year, with a range of 
>>    1000--9999, two digits giving the month of the year, with a range of 
>>    01--12, two digits giving the day of the month, with a range of 
>>    01--31, two digits giving the hour of the day, with a range of 
>>    00--23, two digits giving minutes past the hour, with a range of 
>>    00--59, and finally, two digits giving seconds past the minute, with 
>>    a range of 00--60 (with 60 being used only at a leap second). Years 
>>    in the tenth century, and earlier, cannot be expressed. This is not 
>>    considered a serious defect of the protocol. 
>> 
>>    The optional digits, which are preceded by a period, give decimal 
>>    fractions of a second. These may be given to whatever precision is 
>>    appropriate to the circumstance, however implementations MUST NOT add 
>>    precision to time-vals where that precision does not exist in the 
>>    underlying value being transmitted. 
>> 
>>    Symbolically, a time-val may be viewed as 
>> 
>>   YYYYMMDDHHMMSS.sss 
>> 
>>    The "." and subsequent digits ("sss") are optional. However the "." 
>>    MUST NOT appear unless at least one following digit also appears. 
>> 
> 
> `MLSxParser`, however, uses `SimpleDateFormat("yyyyMMddhhmmss")` (which is wrong b/c it uses `hh` instead of `HH` and doesn't account for optional `.sss`) to parse modify/create facts and ignore any parse exceptions.
> 
> `FtpClient` actually already has and uses `SimpleDateFormat` w/ right formats in `getLastModified` where it parses MDTM response, the patch refactors the code to reuse the same `SimpleDateFormat` in `MLSxParser`.
> 
> testing:
> * [x] tier1
> * [x] `test/jdk/sun/net` on `{linux,windows,macosx}-x64`

Igor Ignatyev has updated the pull request incrementally with one additional commit since the last revision:

  added test

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/776/files
  - new: https://git.openjdk.java.net/jdk/pull/776/files/a2867539..7a1c0505

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=776&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=776&range=00-01

  Stats: 192 lines in 1 file changed: 192 ins; 0 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/776.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/776/head:pull/776

PR: https://git.openjdk.java.net/jdk/pull/776


More information about the net-dev mailing list