Skip to content

Commit 689d7da

Browse files
fix: adding an explicit check to prevent empty publishes (#1376)
* fix: adding an explicit check to prevent empty publishes * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 70df54c commit 689d7da

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ implementation 'com.google.cloud:google-cloud-pubsub'
5858
If you are using Gradle without BOM, add this to your dependencies:
5959

6060
```Groovy
61-
implementation 'com.google.cloud:google-cloud-pubsub:1.120.22'
61+
implementation 'com.google.cloud:google-cloud-pubsub:1.120.23'
6262
```
6363

6464
If you are using SBT, add this to your dependencies:
6565

6666
```Scala
67-
libraryDependencies += "com.google.cloud" % "google-cloud-pubsub" % "1.120.22"
67+
libraryDependencies += "com.google.cloud" % "google-cloud-pubsub" % "1.120.23"
6868
```
6969

7070
## Authentication

google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/Publisher.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,10 @@ private ApiFuture<PublishResponse> publishCall(OutstandingBatch outstandingBatch
462462
}
463463

464464
private void publishOutstandingBatch(final OutstandingBatch outstandingBatch) {
465+
if (outstandingBatch.size() == 0) {
466+
logger.log(Level.WARNING, "Attempted to publish batch with zero messages.");
467+
return;
468+
}
465469
final ApiFutureCallback<PublishResponse> futureCallback =
466470
new ApiFutureCallback<PublishResponse>() {
467471
@Override

0 commit comments

Comments
 (0)