-
Notifications
You must be signed in to change notification settings - Fork 85
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
feat: introduce java.time
methods and variables
#2780
Conversation
@lqiu96 This check (java 8 only) is failing with
The problem is with Lines 95 to 102 in 5f1b30a
|
.appendLiteral(' ') | ||
.optionalEnd() | ||
.optionalStart() | ||
.appendOffset("+HH:MM", "+00:00") | ||
.appendZoneOrOffsetId() | ||
.optionalEnd() | ||
.optionalStart() | ||
.appendZoneText(TextStyle.SHORT) | ||
.optionalEnd() | ||
.optionalStart() | ||
.appendLiteral('Z') | ||
.optionalEnd() | ||
.toFormatter() | ||
.withZone(ZoneOffset.UTC); |
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.
This fix works for the current tests. Note that the literal Z
is dropped from the config because appendZoneOrOffsetId()
uses Z
as the no-zone string
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.
Added a test for +00:00
in 260c835
|
||
package com.google.cloud.bigquery.storage.util; | ||
|
||
public class TimeConversionUtils { |
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.
Why is this added in BQStorage and not used from sdk-platform-java?
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.
They are functions only used in BQS so far (confirmed other repos don't need them). However, the reason is simply because it's faster to implement here than waiting for a new release of gax with the utilities we have here. What if we follow up in gax and temporarily have these functions in this repo?
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.
What if we follow up in gax and temporarily have these functions in this repo?
Sure. Can we make this class package-private until we migrate this to Gax? Can you also create an issue in sdk-platform-java for this?
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.
As discussed internally, left as @InternalApi
, referencing the new issue in sdk-platform: googleapis/sdk-platform-java#3412
<to>java.time.Duration</to> | ||
</difference> | ||
<difference> | ||
<!--The retryDelay field is used by ApiResultRetryAlgorithm, which is marked as @InternalApi--> |
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.
Errors$IsRetryableStatusResult is still marked as public even if it's only used by ApiResultRetryAlgorithm
in the BQStorage SDK. I think it's still accessible which is problematic.
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.
@PhongChuong what's the rationale of Errors$IsRetryableStatusResult
being public? Is it similar to the case of ApiResultRetryAlgorithm
"visible for technical reasons"?
Also, does it make sense to change their datatypes directly, without threeten
alternatives as done currently?
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.
I don't know the historical reason as to why it is public but from the code, I would assume that is it "visible for technical reasons". Specifically, while IsRetryableStatusResult
is public, it seems to be only used in ApiResultRetryAlgorithm
and it is not part of the return value. I think it would be okay to change the datatype directly here.
@yirutang , what do you think?
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.
I am fine making it private. I don't think external user should use it.
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.
Overall the changes looks good. Thank you for the PR, it looks like a lot of work tracking down all the changes needed.
<to>java.time.Duration</to> | ||
</difference> | ||
<difference> | ||
<!--The retryDelay field is used by ApiResultRetryAlgorithm, which is marked as @InternalApi--> |
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.
I don't know the historical reason as to why it is public but from the code, I would assume that is it "visible for technical reasons". Specifically, while IsRetryableStatusResult
is public, it seems to be only used in ApiResultRetryAlgorithm
and it is not part of the return value. I think it would be okay to change the datatype directly here.
@yirutang , what do you think?
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.
LGTM. Added a small comment if you could address
This PR introduces
java.time
alternatives to existingorg.threeten.bp.*
methods, as well as switching internal variables (if any) tojava.time
The main constraint is to keep the changes backwards compatible, so for each existing threeten method "
method1(org.threeten.bp.Duration)
" we will add an alternative with a Duration (or Timestamp when applicable) suffix: "method1Duration(java.time.Duration)
".For most cases, the implementation will be held in the
java.time
method and the old threeten method will just delegate the call to it. However, for the case of abstract classes, the implementation will be kept in the threeten method to avoid breaking changes (i.e. users that already overloaded the method in their user code).