-
Notifications
You must be signed in to change notification settings - Fork 122
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 variables and methods #3495
Conversation
google-cloud-spanner/src/main/java/com/google/cloud/spanner/CompositeTracer.java
Show resolved
Hide resolved
google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java
Outdated
Show resolved
Hide resolved
google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerRpc.java
Show resolved
Hide resolved
@@ -275,7 +275,7 @@ public void onSessionCreateFailure(Throwable t, int createFailureForSessionCount | |||
|
|||
private static void maybeWaitForSessionCreation( | |||
SessionPoolOptions sessionPoolOptions, ApiFuture<SessionReference> future) { | |||
org.threeten.bp.Duration waitDuration = sessionPoolOptions.getWaitForMinSessions(); | |||
java.time.Duration waitDuration = sessionPoolOptions.getWaitForMinSessions(); |
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.
nit: java.time.Duration
is already imported in this class. Can't we just remove org.threeten.bp.
@@ -109,7 +108,7 @@ public void attemptCancelled() { | |||
} | |||
|
|||
@Override | |||
public void attemptFailed(Throwable error, Duration delay) { | |||
public void attemptFailed(Throwable error, org.threeten.bp.Duration delay) { |
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.
nit: Can we import java.time.Duration
so that we can remove java.time.
in attemptFailedDuration
method? https://github.com/googleapis/java-spanner/blob/main/google-cloud-spanner/src/main/java/com/google/cloud/spanner/CompositeTracer.java#L119
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.
Done
@Override | ||
public void attemptFailed(Throwable error, Duration delay) { | ||
public void attemptFailedDuration(Throwable error, java.time.Duration delay) { |
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.
nit: Can we import java.time.Duration
?
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.
Done
@@ -63,8 +66,8 @@ public class SessionPoolOptions { | |||
@Deprecated private final long initialWaitForSessionTimeoutMillis; | |||
|
|||
private final boolean autoDetectDialect; | |||
private final Duration waitForMinSessions; | |||
private final Duration acquireSessionTimeout; | |||
private final java.time.Duration waitForMinSessions; |
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.
nit: We can import java.time.Duration
so that in future we don't have a confusion on which class to use
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.
and also it avoids so many changes in the code which is not really necessary.
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.
Done
@diegomarquezp Can we make sure following in all the files?
|
@sakthivelmanii Thanks for the review! Before switching to Promoting |
@@ -106,26 +106,26 @@ public boolean hasDuration() { | |||
}); | |||
} | |||
|
|||
org.threeten.bp.Duration asDuration() { | |||
java.time.Duration asDuration() { |
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.
need to keep this one in favor of com.google.protobuf.Duration
google-cloud-spanner/src/main/java/com/google/cloud/spanner/CompositeTracer.java
Show resolved
Hide resolved
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. Spanner team for approval.
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).