Skip to content

Commit fe6dd7d

Browse files
committed
---
yaml --- r: 28271 b: refs/heads/pubsub-ordering-keys c: 0b00228 h: refs/heads/master i: 28269: aa202e7 28267: f538d3b 28263: b91119f 28255: 21c6dc7
1 parent 22d4af2 commit fe6dd7d

3 files changed

Lines changed: 12 additions & 13 deletions

File tree

[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: ec2ecc6d8ef49ab006d93d958d27d8a0a5143e61
158+
refs/heads/pubsub-ordering-keys: 0b002280af0d6253fe50bf3f073749a2c6b86853
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 & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,12 @@ public String getTopicNameString() {
216216
* @return the message ID wrapped in a future.
217217
*/
218218
public ApiFuture<String> publish(PubsubMessage message) {
219-
if (shutdown.get()) {
220-
throw new IllegalStateException("Cannot publish on a shut-down publisher.");
221-
}
219+
Preconditions.checkState(!shutdown.get(), "Cannot publish on a shut-down publisher.");
222220

223221
final String orderingKey = message.getOrderingKey();
224-
if (orderingKey != null && !orderingKey.isEmpty() && !enableMessageOrdering) {
225-
throw new IllegalStateException(
226-
"Cannot publish a message with an ordering key when message ordering is not enabled.");
227-
}
222+
Preconditions.checkState(
223+
orderingKey != null && !orderingKey.isEmpty() && !enableMessageOrdering,
224+
"Cannot publish a message with an ordering key when message ordering is not enabled.");
228225

229226
final OutstandingPublish outstandingPublish =
230227
new OutstandingPublish(messageTransform.apply(message));
@@ -361,9 +358,13 @@ private void publishOutstandingBatch(final OutstandingBatch outstandingBatch) {
361358
public void onSuccess(PublishResponse result) {
362359
try {
363360
if (result.getMessageIdsCount() != outstandingBatch.size()) {
364-
Throwable t = new IllegalStateException(String.format(
365-
"The publish result count %s does not match " + "the expected %s results. Please contact Cloud Pub/Sub support "
366-
+ "if this frequently occurs", result.getMessageIdsCount(), outstandingBatch.size()));
361+
Throwable t =
362+
new IllegalStateException(
363+
String.format(
364+
"The publish result count %s does not match "
365+
+ "the expected %s results. Please contact Cloud Pub/Sub support "
366+
+ "if this frequently occurs",
367+
result.getMessageIdsCount(), outstandingBatch.size()));
367368
for (OutstandingPublish oustandingMessage : outstandingBatch.outstandingPublishes) {
368369
oustandingMessage.publishResult.setException(t);
369370
}

branches/pubsub-ordering-keys/google-cloud-clients/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/PublisherImplTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import java.util.concurrent.TimeUnit;
4848
import org.easymock.EasyMock;
4949
import org.junit.After;
50-
import org.junit.Assert;
5150
import org.junit.Before;
5251
import org.junit.Test;
5352
import org.junit.runner.RunWith;
@@ -413,7 +412,6 @@ public void testEnableMessageOrdering_overwritesMaxAttempts() throws Exception {
413412
publisher.shutdown();
414413
}
415414

416-
417415
@Test
418416
public void testEnableMessageOrdering_dontSendWhileInflight() throws Exception {
419417
// Set maxAttempts to 1 and enableMessageOrdering to true at the same time.

0 commit comments

Comments
 (0)