-
Notifications
You must be signed in to change notification settings - Fork 42
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
Use java.time.Instant instead of java.text.SimpleDateFormat #469
Conversation
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.
Please remove all println statements from the codebase
@gferon Thank you for raising this PR . the team will have a look into this |
Sure, I mostly wanted to first know which approach you favor. EDIT: done. |
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.
Hi @gferon
Thank you for raising the PR, I've reviewed it and it looks good to me, Can you remove the println statements and also update the tests accordingly ?
@gferon, thanks a lot for addressing the comment, can you please update the unit tests as well to use |
I updated the PR description. I think it's actually good to keep the old way of doing it in the tests, to avoid testing a bug itself (which was happening before). |
Hi @pmathew92 could you maybe at least approve the workflow runs so I can fix any CI issues before we move forward? The bug is still out there and it's not a nice one. |
@gferon Apologies . I have approved the workflow runs. Looks like the merge is blocked due to not being signed commits.Could you please sign your commits |
Hi, any update on this? |
83c6e64
to
1376408
Compare
1376408
to
13a5c3e
Compare
@pmathew92 I have signed my commits, not sure why it's a requirement in the first place. |
@gferon We have merged the PR . Thank you for your contributions |
📋 Changes
After spending quite some time trying to understand why our access tokens would not be refreshed, I realized that something was wrong with the
expiresAt
field. The issue affects (at least) Android because the UTC timezone is added in the format while the formatter itself is timezone-unaware.With the following added print statements, you can observe that the
Credentials.expiresAt
is formatted from local time with an appended Z, which means we lose the timezone information.Making sure all
SimpleDateFormat
are set to the UTC timezone fixes the issue, but sincejava.util.Date
is notably confusing to work with, a better fix is to switch tojava.time.Instant
and useInstant.toString()
as well asInstant.parse()
which work with ISO-8601 formatting.🎯 Testing
Making sure the tests still use
SimpleDateFormat
is a great way to avoid having the actual implementation have the same bug than the tests. Unit tests should be good enough in that case.