Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pub/Sub ApiFutures.addCallback() deprecated #3861

Closed
anguillanneuf opened this issue Oct 25, 2018 · 2 comments
Closed

Pub/Sub ApiFutures.addCallback() deprecated #3861

anguillanneuf opened this issue Oct 25, 2018 · 2 comments
Assignees
Labels
type: question Request for information or clarification. Not an issue.

Comments

@anguillanneuf
Copy link
Contributor

What should people use to add an asynchronous callback on the Api Futures instead now since it's deprecated?

@vam-google
Copy link
Contributor

vam-google commented Oct 25, 2018

You can use

ApiFutures.addCallback(final ApiFuture<V> future, final ApiFutureCallback<? super V> callback, Executor executor)

To get identical behavior to the deprecated method, pass guava's com.google.common.util.concurrent.MoreExecutors.directExecutor() as the last parameter, but please do not do it unless you really know what you are doing. It is better to use separate thread executor, because using direct executor will execute the callback under future's internal locks and may break its behavior if the callback is not properly implemented.

@vam-google vam-google added the type: question Request for information or clarification. Not an issue. label Oct 25, 2018
@anguillanneuf
Copy link
Contributor Author

anguillanneuf commented Oct 25, 2018

Thank you! I see the file now:

https://github.com/googleapis/api-common-java/blob/master/src/main/java/com/google/api/core/ApiFutures.java

We should update this sample because it is linked to our docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

3 participants