Skip to content

Commit c68bc89

Browse files
committed
Passes the build
1 parent a4c9e68 commit c68bc89

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

okhttp-clients/src/main/java/com/palantir/remoting3/okhttp/RemotingConcurrencyLimiter.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
* <ol>
4444
* <li>Fix concurrency bug - upstream has a race between starting finishing the window and running requests.</li>
4545
* <li>Store the last update time as well as the next update time.</li>
46-
* <li>Use the last update time to pre-emptively close the window when a request is dropped, instead of waiting.</li>
46+
* <li>Use the last update time to pre-emptively close the window when a request is dropped, instead of waiting.
47+
* Do this before handing back any tokens.</li>
4748
* <li>Remove the builder, and instead have a static factory method.</li>
4849
* <li>Change code style to match Palantir baseline.</li>
4950
* </ol>
@@ -117,10 +118,10 @@ public void onIgnore() {
117118

118119
@Override
119120
public void onDropped() {
120-
inFlight.decrementAndGet();
121-
token.release();
122121
sample.getAndUpdate(current -> current.addDroppedSample(currentMaxInFlight));
123122
maybeUpdateWindow(System.nanoTime(), () -> startTime > lastUpdateTime, unused -> true);
123+
inFlight.decrementAndGet();
124+
token.release();
124125
}
125126

126127
});
@@ -156,7 +157,7 @@ private void updateWindow(long endTime, Predicate<ImmutableSampleWindow> shouldF
156157
}
157158
}
158159

159-
private boolean isWindowReady(ImmutableSampleWindow sample) {
160-
return sample.getCandidateRttNanos() < Long.MAX_VALUE && sample.getSampleCount() > windowSize;
160+
private boolean isWindowReady(ImmutableSampleWindow window) {
161+
return window.getCandidateRttNanos() < Long.MAX_VALUE && window.getSampleCount() > windowSize;
161162
}
162163
}

okhttp-clients/src/test/java/com/palantir/remoting3/okhttp/ConcurrencyLimitersTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ public void testFifo() throws ExecutionException, InterruptedException {
5656
first.get().onIgnore();
5757
assertThat(second.isDone()).isTrue();
5858
}
59-
}
59+
}

okhttp-clients/src/test/java/com/palantir/remoting3/okhttp/FlowControlTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@
5151
* to try different strategies.
5252
* <p>
5353
* It is run in CI, but only to prevent code breakages - this is in general an expensive test which should be run
54-
* as a dev tool.
54+
* as a dev tool. If you want to run for dev purposes, please increase REQUESTS_PER_THREAD.
5555
*/
5656
public final class FlowControlTest {
5757
private static final Logger log = LoggerFactory.getLogger(FlowControlTest.class);
5858
private static final Duration GRACE = Duration.ofMinutes(2);
59-
private static final int REQUESTS_PER_THREAD = System.getenv("CI") == null ? 1000 : 1;
59+
private static final int REQUESTS_PER_THREAD = 5;
6060
private static final ConcurrencyLimiters limiters = new ConcurrencyLimiters();
6161
private static ListeningExecutorService executorService;
6262

@@ -107,7 +107,7 @@ private Stream<Worker> createWorkers(
107107
avgRetries));
108108
}
109109

110-
private static class Worker implements Runnable {
110+
private static final class Worker implements Runnable {
111111
private final Supplier<BackoffStrategy> backoffFactory;
112112
private final ConcurrencyLimiter limiter;
113113
private final Duration successDuration;

0 commit comments

Comments
 (0)