This repository was archived by the owner on Sep 26, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
gax/src/main/java/com/google/api/gax/batching Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -213,6 +213,8 @@ public ApiFuture<ElementResultT> add(ElementT element) {
213
213
// will only be done from a single calling thread.
214
214
Preconditions .checkState (closeFuture == null , "Cannot add elements on a closed batcher" );
215
215
216
+ long bytesSize = batchingDescriptor .countBytes (element );
217
+
216
218
// This is not the optimal way of throttling. It does not send out partial batches, which
217
219
// means that the Batcher might not use up all the resources allowed by FlowController.
218
220
// The more efficient implementation should look like:
@@ -230,7 +232,7 @@ public ApiFuture<ElementResultT> add(ElementT element) {
230
232
// defer it till we decide on if refactoring FlowController is necessary.
231
233
Stopwatch stopwatch = Stopwatch .createStarted ();
232
234
try {
233
- flowController .reserve (1 , batchingDescriptor . countBytes ( element ) );
235
+ flowController .reserve (1 , bytesSize );
234
236
} catch (FlowControlException e ) {
235
237
// This exception will only be thrown if the FlowController is set to ThrowException behavior
236
238
throw FlowControlRuntimeException .fromFlowControlException (e );
You can’t perform that action at this time.
0 commit comments