GoogleCloudPlatform / spring-cloud-gcp

New home for Spring Cloud GCP development starting with version 2.0.
Apache License 2.0
415 stars 307 forks source link

PubSub message conversion exception is silently swallowed #2696

Closed minogin closed 1 month ago

minogin commented 6 months ago

com.google.cloud:spring-cloud-gcp-pubsub:5.0.4

When using com.google.cloud.spring.pubsub.core.subscriber.PubSubSubscriberTemplate#pullAndConvertAsync and an exception happens during message conversion the future just never completes and you never get neither exception nor the message.

@Override
  public <T> CompletableFuture<List<ConvertedAcknowledgeablePubsubMessage<T>>> pullAndConvertAsync(
      String subscription, Integer maxMessages, Boolean returnImmediately, Class<T> payloadType) {
    final CompletableFuture<List<ConvertedAcknowledgeablePubsubMessage<T>>> completableFuture =
        new CompletableFuture<>();

    this.pullAsync(subscription, maxMessages, returnImmediately)
        .whenComplete(
            (ackableMessages, exception) -> {
                if (exception != null) {
                  completableFuture.completeExceptionally(exception);
                  return;
                }
                completableFuture.complete(
                    this.toConvertedAcknowledgeablePubsubMessages(payloadType, ackableMessages));
            });

    return completableFuture;
  }

The problem is here:

completableFuture.complete(
                    this.toConvertedAcknowledgeablePubsubMessages(payloadType, ackableMessages));

when toConvertedAcknowledgeablePubsubMessages throws an exception.

ldetmer commented 1 month ago

Fixed in release 5.5.1