File tree 2 files changed +12
-3
lines changed
main/java/com/google/cloud/pubsub/v1
test/java/com/google/cloud/pubsub/v1
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -216,8 +216,10 @@ private void initialize() {
216
216
.setSubscription (subscription )
217
217
.setStreamAckDeadlineSeconds (60 )
218
218
.setClientId (clientId )
219
- .setMaxOutstandingMessages (flowControlSettings .getMaxOutstandingElementCount ())
220
- .setMaxOutstandingBytes (flowControlSettings .getMaxOutstandingRequestBytes ())
219
+ .setMaxOutstandingMessages (
220
+ valueOrZero (flowControlSettings .getMaxOutstandingElementCount ()))
221
+ .setMaxOutstandingBytes (
222
+ valueOrZero (flowControlSettings .getMaxOutstandingRequestBytes ()))
221
223
.build ());
222
224
223
225
/**
@@ -281,6 +283,10 @@ public void run() {
281
283
MoreExecutors .directExecutor ());
282
284
}
283
285
286
+ private Long valueOrZero (Long value ) {
287
+ return value != null ? value : 0 ;
288
+ }
289
+
284
290
private boolean isAlive () {
285
291
State state = state (); // Read the state only once.
286
292
return state == State .RUNNING || state == State .STARTING ;
Original file line number Diff line number Diff line change 19
19
import static org .junit .Assert .assertEquals ;
20
20
import static org .junit .Assert .assertTrue ;
21
21
22
+ import com .google .api .gax .batching .FlowControlSettings ;
22
23
import com .google .api .gax .core .ExecutorProvider ;
23
24
import com .google .api .gax .core .FixedExecutorProvider ;
24
25
import com .google .api .gax .core .InstantiatingExecutorProvider ;
@@ -238,6 +239,8 @@ private Builder getTestSubscriberBuilder(MessageReceiver receiver) {
238
239
.setCredentialsProvider (NoCredentialsProvider .create ())
239
240
.setClock (fakeExecutor .getClock ())
240
241
.setParallelPullCount (1 )
241
- .setMaxDurationPerAckExtension (Duration .ofSeconds (5 ));
242
+ .setMaxDurationPerAckExtension (Duration .ofSeconds (5 ))
243
+ .setFlowControlSettings (
244
+ FlowControlSettings .newBuilder ().setMaxOutstandingElementCount (1000L ).build ());
242
245
}
243
246
}
You can’t perform that action at this time.
0 commit comments