Skip to content

Incorrect error handling in ConsumerBase.receiveAsync  #249

Closed

Description

@jai1

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

Activity

  1. added
    type/bug
    on Feb 27, 2017
  2. added this to the 1.17 milestone on Feb 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions