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) {
213213 // will only be done from a single calling thread.
214214 Preconditions .checkState (closeFuture == null , "Cannot add elements on a closed batcher" );
215215
216+ long bytesSize = batchingDescriptor .countBytes (element );
217+
216218 // This is not the optimal way of throttling. It does not send out partial batches, which
217219 // means that the Batcher might not use up all the resources allowed by FlowController.
218220 // The more efficient implementation should look like:
@@ -230,7 +232,7 @@ public ApiFuture<ElementResultT> add(ElementT element) {
230232 // defer it till we decide on if refactoring FlowController is necessary.
231233 Stopwatch stopwatch = Stopwatch .createStarted ();
232234 try {
233- flowController .reserve (1 , batchingDescriptor . countBytes ( element ) );
235+ flowController .reserve (1 , bytesSize );
234236 } catch (FlowControlException e ) {
235237 // This exception will only be thrown if the FlowController is set to ThrowException behavior
236238 throw FlowControlRuntimeException .fromFlowControlException (e );
You can’t perform that action at this time.
0 commit comments