File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
main/java/com/google/cloud/pubsub/v1
test/java/com/google/cloud/pubsub/v1 Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -216,8 +216,10 @@ private void initialize() {
216216 .setSubscription (subscription )
217217 .setStreamAckDeadlineSeconds (60 )
218218 .setClientId (clientId )
219- .setMaxOutstandingMessages (flowControlSettings .getMaxOutstandingElementCount ())
220- .setMaxOutstandingBytes (flowControlSettings .getMaxOutstandingRequestBytes ())
219+ .setMaxOutstandingMessages (
220+ valueOrZero (flowControlSettings .getMaxOutstandingElementCount ()))
221+ .setMaxOutstandingBytes (
222+ valueOrZero (flowControlSettings .getMaxOutstandingRequestBytes ()))
221223 .build ());
222224
223225 /**
@@ -281,6 +283,10 @@ public void run() {
281283 MoreExecutors .directExecutor ());
282284 }
283285
286+ private Long valueOrZero (Long value ) {
287+ return value != null ? value : 0 ;
288+ }
289+
284290 private boolean isAlive () {
285291 State state = state (); // Read the state only once.
286292 return state == State .RUNNING || state == State .STARTING ;
Original file line number Diff line number Diff line change 1919import static org .junit .Assert .assertEquals ;
2020import static org .junit .Assert .assertTrue ;
2121
22+ import com .google .api .gax .batching .FlowControlSettings ;
2223import com .google .api .gax .core .ExecutorProvider ;
2324import com .google .api .gax .core .FixedExecutorProvider ;
2425import com .google .api .gax .core .InstantiatingExecutorProvider ;
@@ -238,6 +239,8 @@ private Builder getTestSubscriberBuilder(MessageReceiver receiver) {
238239 .setCredentialsProvider (NoCredentialsProvider .create ())
239240 .setClock (fakeExecutor .getClock ())
240241 .setParallelPullCount (1 )
241- .setMaxDurationPerAckExtension (Duration .ofSeconds (5 ));
242+ .setMaxDurationPerAckExtension (Duration .ofSeconds (5 ))
243+ .setFlowControlSettings (
244+ FlowControlSettings .newBuilder ().setMaxOutstandingElementCount (1000L ).build ());
242245 }
243246}
You can’t perform that action at this time.
0 commit comments