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

Incorrect error handling in ConsumerBase.receiveAsync #249

Closed
jai1 opened this issue Feb 27, 2017 · 0 comments
Closed

Incorrect error handling in ConsumerBase.receiveAsync #249

jai1 opened this issue Feb 27, 2017 · 0 comments
Labels
type/bug The PR fixed a bug or issue reported a bug
Milestone

Comments

@jai1
Copy link
Contributor

jai1 commented Feb 27, 2017

Expected behavior

If the listener is unavailable or state is not ready the function should return exception.

Actual behavior

It doesn't, as seen below the return statement is missing before FutureUtil


    @Override
    public CompletableFuture<Message> receiveAsync() {

        if (listener != null) {
            FutureUtil.failedFuture(new PulsarClientException.InvalidConfigurationException(
                    "Cannot use receive() when a listener has been set"));
        }

        switch (getState()) {
        case Ready:
        case Connecting:
            break; // Ok
        case Closing:
        case Closed:
            FutureUtil.failedFuture(new PulsarClientException.AlreadyClosedException("Consumer already closed"));
        case Failed:
        case Uninitialized:
            FutureUtil.failedFuture(new PulsarClientException.NotConnectedException());
        }

        return internalReceiveAsync();
    }

Steps to reproduce

Code Inspection

System configuration

Pulsar version: x.y

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

No branches or pull requests

2 participants