Skip to content

Commit 3dbb61e

Browse files
grpc-api/stub: Changes for InternalTimeUtils and TimeUtils files as per review comments
1 parent af01908 commit 3dbb61e

3 files changed

Lines changed: 30 additions & 4 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2024 The gRPC Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.grpc;
18+
19+
import java.time.Duration;
20+
21+
@Internal
22+
public final class InternalTimeUtils {
23+
public static long convert(Duration duration) {
24+
return TimeUtils.convertToNanos(duration);
25+
}
26+
}

api/src/main/java/io/grpc/TimeUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
import java.time.Duration;
2020

21-
public final class TimeUtils {
22-
public static long convertToNanos(Duration duration) {
21+
final class TimeUtils {
22+
static long convertToNanos(Duration duration) {
2323
try {
2424
return duration.toNanos();
2525
} catch (ArithmeticException tooBig) {

stub/src/main/java/io/grpc/stub/AbstractStub.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package io.grpc.stub;
1818

1919
import static com.google.common.base.Preconditions.checkNotNull;
20-
import static io.grpc.TimeUtils.convertToNanos;
20+
import static io.grpc.InternalTimeUtils.convert;
2121

2222
import io.grpc.CallCredentials;
2323
import io.grpc.CallOptions;
@@ -152,7 +152,7 @@ public final S withDeadlineAfter(long duration, TimeUnit unit) {
152152
}
153153

154154
public final S withDeadlineAfter(Duration duration) {
155-
return withDeadlineAfter(convertToNanos(duration), TimeUnit.NANOSECONDS);
155+
return withDeadlineAfter(convert(duration), TimeUnit.NANOSECONDS);
156156
}
157157

158158
/**

0 commit comments

Comments
 (0)