question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PublisherFactory returns PublisherInterface instead of Publisher

See original GitHub issue

Describe the bug There was a change in the PublisherFactory in com.google.cloud:spring-cloud-gcp-pubsub version 2.0.6 used in com.google.cloud:spring-cloud-gcp-starter-pubsub which caused one of our applications to have a compilation error on the following line:

pubsubTemplate.getPublisherFactory.createPublisher(topic).publishAllOutstanding()

The reason for this is as follows:

In version 2.0.5 the PublisherFactory returns a Publisher

public interface PublisherFactory {
    Publisher createPublisher(String topic);
}

while in v 2.0.6 it returns a PublisherInterface

public interface PublisherFactory {
    PublisherInterface createPublisher(String topic);
}

The PublisherInterface doesn’t expose the Publisher method publishAllOutstanding().

This change is not mentioned in the change log for (release 2.0.6)[https://github.com/GoogleCloudPlatform/spring-cloud-gcp/releases/tag/v2.0.6].

The change was part of PR #548. In this change I notice that the CachingPublisherFactory implementation of PublisherFactory was also change to return a PublisherInterface instead of a Publisher, but the DefaultPublisherFactory was not (and still returns a Publisher).

Since this isn’t mentioned in the release notes, I wonder if this change was intentional? ~And also whether we can fix our compilation error by casting to a DefaultPublisherFactory going forward, or~ should assume that the publishAllOutstanding() is not intended to be exposed (as it’s not part of the PublisherInterface).

Update: casting to DefaultPublisherFactory didn’t work.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
elefeintcommented, Dec 14, 2021

I’ve filed googleapis/java-pubsub#949 in the client library – if it’s meant to be a public surface, we should support it. If not, the downcasting workaround is fine.

0reactions
elefeintcommented, Dec 23, 2021

It’s correct that most health indicators are enabled by default, but they should not be tied to Liveness group, which is what controls the Kubernetes restarts. So somehow these custom informational indicators are making their way to management.endpoint.health.group.liveness.include.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PublisherFactory (javadoc 3.0.0 API)
The publisher factory interface that can create publishers. ... configuration to create a Publisher; Returns: an Implementation of a PublisherInterface.
Read more >
Publish messages to topics | Cloud Pub/Sub - Google Cloud
A publisher application creates and sends messages to a topic. Pub/Sub offers at-least-once message delivery and best-effort ordering to existing subscribers.
Read more >
CachingPublisherFactory (Spring Cloud GCP 2.0.7 API)
The caching implementation of the PublisherFactory . Creates Publisher s for topics once using delegate, caches and reuses them. ... Returns the delegate....
Read more >
PublisherFactory returns PublisherInterface instead of Publisher ...
public interface PublisherFactory { Publisher createPublisher(String topic); }. while in v 2.0.6 it returns a PublisherInterface
Read more >
151. Google Cloud Pub/Sub
The PublisherFactory provides a Google Cloud Java Client for Pub/Sub Publisher ... objectMapper) { return new JacksonPubSubMessageConverter(objectMapper); }.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found