Skip to content

Commit 206887e

Browse files
committed
---
yaml --- r: 28277 b: refs/heads/pubsub-ordering-keys c: 92a7bf4 h: refs/heads/master i: 28275: a4f5829
1 parent 9704e70 commit 206887e

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

  • branches/pubsub-ordering-keys/google-cloud-clients/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ refs/tags/v0.72.0: a7703f2593ba312c0b2dde6fdfd4f5c764bb55ac
155155
refs/tags/v0.73.0: 21241ea8be9439cc5764c4944cdce21d34ce4f9e
156156
refs/tags/v0.74.0: 9d1f733dbbf790de7b494418523b69c4a9a57638
157157
refs/heads/ignoretest: 23c412ae07af3d0ab1caa2d44d5bc5c0ccb8b31d
158-
refs/heads/pubsub-ordering-keys: 142196cae7583aa38142f86aa3830faaf43925fb
158+
refs/heads/pubsub-ordering-keys: 92a7bf4760df78e7379b6ef3599374650a3d48e3
159159
refs/tags/v0.75.0: c3673089ae09a897c1b4cf7dfe167fe4f8ab32fb
160160
refs/tags/v0.76.0: 395b016826d3ddf9cb8b34919636df15a4dbd032
161161
refs/tags/v0.77.0: 28a85a77883ccf5d48f297fd0ef3b3dca6ce01f0

branches/pubsub-ordering-keys/google-cloud-clients/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/Publisher.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public ApiFuture<String> publish(PubsubMessage message) {
220220

221221
final String orderingKey = message.getOrderingKey();
222222
Preconditions.checkState(
223-
orderingKey != null && !orderingKey.isEmpty() && !enableMessageOrdering,
223+
orderingKey.isEmpty() || enableMessageOrdering,
224224
"Cannot publish a message with an ordering key when message ordering is not enabled.");
225225

226226
final OutstandingPublish outstandingPublish =
@@ -357,7 +357,7 @@ private void publishOutstandingBatch(final OutstandingBatch outstandingBatch) {
357357
@Override
358358
public void onSuccess(PublishResponse result) {
359359
try {
360-
if (result.getMessageIdsCount() != outstandingBatch.size()) {
360+
if (result == null || result.getMessageIdsCount() != outstandingBatch.size()) {
361361
outstandingBatch.onFailure(
362362
new IllegalStateException(
363363
String.format(
@@ -387,15 +387,15 @@ public void onFailure(Throwable t) {
387387
ApiFutures.addCallback(publishCall(outstandingBatch), futureCallback, directExecutor());
388388
} else {
389389
// If ordering key is specified, publish the batch using the sequential executor.
390-
sequentialExecutor.submit(
391-
outstandingBatch.orderingKey,
392-
new Callable<ApiFuture<PublishResponse>>() {
393-
public ApiFuture<PublishResponse> call() {
394-
ApiFuture<PublishResponse> future = publishCall(outstandingBatch);
395-
ApiFutures.addCallback(future, futureCallback, directExecutor());
396-
return future;
397-
}
398-
});
390+
ApiFuture<PublishResponse> future =
391+
sequentialExecutor.submit(
392+
outstandingBatch.orderingKey,
393+
new Callable<ApiFuture<PublishResponse>>() {
394+
public ApiFuture<PublishResponse> call() {
395+
return publishCall(outstandingBatch);
396+
}
397+
});
398+
ApiFutures.addCallback(future, futureCallback, directExecutor());
399399
}
400400
}
401401

0 commit comments

Comments
 (0)