spring-attic / spring-cloud-gcp

Integration for Google Cloud Platform APIs with Spring
Apache License 2.0
706 stars 693 forks source link

Bound the type of PubSubSubscriberOperations#ack parameter #2538

Closed celcius112 closed 4 years ago

celcius112 commented 4 years ago

At the moment PubSubSubscriberOperations's #ack, #nack and #modifyAckDeadline methods accept a Collection of AcknowledgeablePubsubMessage. It would be appreciated to bound this Collection so that, for instance, a List of ConvertedAcknowledgeablePubsubMessage could be used as parameter.

This would bring a breaking change as the signature of the public interface PubSubSubscriberOperations would be modified.

As a temporary workaround, we can wrap our list in a Collections.unmodifiableList in order to downcast the type, for instance

List<ConvertedAcknowledgeablePubsubMessage<T>> messages...
pubSubTemplate.ack(Collections.unmodifiableList(messages));

but this is less than optimal.

If necessary, and since the modification is quite trivial, I can provide a PR.

meltsufin commented 4 years ago

What if we changed it to ack(Collection<? extends AcknowledgeablePubsubMessage> messages)? I think that would work without introducing a breaking change.

celcius112 commented 4 years ago

That's what I have in mind. However this is a breaking change, albeit a minor one, for those implementing PubSubSubscriberOperations since the signature of the public interface's methods does change.

I wouldn't mind making this change, but I do not consider myself being in the best place to take this decision :)

meltsufin commented 4 years ago

Callers of this method do not need to change their code. So, it's backwards compatible in that sense. Feel free to propose the change in a PR, we can go from there. Thanks!

celcius112 commented 4 years ago

Good enough for me :) Thank you for your time