Skip to content

Commit b8c0e0c

Browse files
committed
11622 : OutlierDetection should use Ticker, not TimeProvider
1 parent c831f1e commit b8c0e0c

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

netty/src/main/java/io/grpc/netty/AbstractNettyHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ public void updateWindow() throws Http2Exception {
199199
pingReturn++;
200200
setPinging(false);
201201

202-
long currentTickerTimeNanos = ticker.read();
203-
long elapsedTime = Math.max(0L,(currentTickerTimeNanos - lastPingTime));
202+
long elapsedTime = (ticker.read() - lastPingTime);
204203
if (elapsedTime == 0) {
205204
elapsedTime = 1;
206205
}

util/src/main/java/io/grpc/util/OutlierDetectionLoadBalancer.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,10 @@ public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
148148
// On the first go we use the configured interval.
149149
initialDelayNanos = config.intervalNanos;
150150
} else {
151-
long currentTickerTimeNanos = ticker.read();
152-
long elapsedTimeNanos = Math.max(0L,(currentTickerTimeNanos - detectionTimerStartNanos));
153151
// If a timer has started earlier we cancel it and use the difference between the start
154152
// time and now as the interval.
155153
initialDelayNanos = Math.max(0L,
156-
config.intervalNanos - elapsedTimeNanos);
154+
config.intervalNanos - Math.max(0L,(ticker.read() - detectionTimerStartNanos)));
157155
}
158156

159157
// If a timer has been previously created we need to cancel it and reset all the call counters

0 commit comments

Comments
 (0)