RFR: 8255405: sun/net/ftp/imp/FtpClient uses SimpleDateFormat in not thread-safe manner
Igor Ignatyev
iignatyev at openjdk.java.net
Tue Oct 27 18:57:17 UTC 2020
On Tue, 27 Oct 2020 12:48:58 GMT, Chris Hegarty <chegar at openjdk.org> wrote:
>> Hi all,
>>
>> could you please review this small and trivial fix?
>>
>> `sun/net/ftp/imp/FtpClient::dateFormats` is an array of `SimpleDateFormat` which are shared among all instances of `FtpClient`. the fact that `SimpleDateFormat` isn't thread-safe renders`FtpClient` to be non-thread-safe as well. the patch makes the only usage of `dateFormats` array, `parseRfc3659TimeValue` method, `synchronized`.
>>
>> the problem was reported in #776
>>
>> Thanks,
>> -- Igor
>
> @iignatev Please evaluate using DateTimeFormatter, as suggested by @dfuch in https://bugs.openjdk.java.net/browse/JDK-8255405?focusedCommentId=14376774&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14376774
Hi Chris,
I've actually thought about `DateTimeFormatter` when I was fixing [8255078](https://bugs.openjdk.java.net/browse/JDK-8255078) / #776, but when I noticed `MDTMformats` and decided to reuse it. anyhow, I have updated `FtpClient` to use `DateTimeFormatter` instead of `SimpleDateFormat`. testing this, I realized that the test added by 8255078 didn't really produce the strings in accordance with RFC 3659; so this PR fixes that as well.
Thanks,
-- Igor
-------------
PR: https://git.openjdk.java.net/jdk/pull/867
More information about the net-dev
mailing list