-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8255405: sun/net/ftp/imp/FtpClient uses SimpleDateFormat in not thread-safe manner #867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
👋 Welcome back iignatyev! A progress list of the required criteria for merging this PR into |
Webrevs
|
@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 Thanks, |
Date result = null; | ||
try { | ||
var d = LocalDateTime.parse(s, RFC3659_DATETIME_FORMAT); | ||
result = Date.from(d.atZone(ZoneOffset.systemDefault()).toInstant()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be ZoneOffset.UTC rather than System default? I thought the date returned by the server were supposed to be in GMT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ZoneOffset.UTC should return GMT as was the case with SimpleDateFormat before the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, thanks for spotting that! I don't know what I was thinking when used systemDefault
here and when was also got tricked by my own test 🤦
LGTM! |
@iignatev This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 47 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
Daniel, Rahul, Chris, thank you for your reviews! /integrate |
@iignatev Since your change was applied there have been 55 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 7e305ad. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Hi all,
could you please review this small and trivial fix?
sun/net/ftp/imp/FtpClient::dateFormats
is an array ofSimpleDateFormat
which are shared among all instances ofFtpClient
. the fact thatSimpleDateFormat
isn't thread-safe rendersFtpClient
to be non-thread-safe as well. the patch makes the only usage ofdateFormats
array,parseRfc3659TimeValue
method,synchronized
.the problem was reported in #776
Thanks,
-- Igor
Progress
Testing
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/867/head:pull/867
$ git checkout pull/867