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

CommandLookupTopic.advertisedListenerName may be blank #14304

Closed
EronWright opened this issue Feb 15, 2022 · 6 comments · Fixed by #14306
Closed

CommandLookupTopic.advertisedListenerName may be blank #14304

EronWright opened this issue Feb 15, 2022 · 6 comments · Fixed by #14306
Labels
type/bug The PR fixed a bug or issue reported a bug

Comments

@EronWright
Copy link
Contributor

EronWright commented Feb 15, 2022

Describe the bug
Some of the language bindings supply an empty string for the advertisedListenerName field of CommandLookupTopic (e.g. Java vs Golang). This confuses the broker, who then fails to apply the default advertised listener for the given server port. This, in turn, leads to an incorrect topic lookup response and a subsequent connection failure.

For background, see [PIP 95] Smart Listener Selection with Multiple Bind Addresses.

To Reproduce
Steps to reproduce the behavior:

  1. Configure a broker with a bind address that is associated with an advertised listener.
  2. Using various language clients, send a topic lookup request to the bind address, without specifying an advertised listener. Expect the default advertised listener for that binding to be used.
  3. Observe that some clients receive the correct advertised listener, others don't.

Expected behavior
Expect the binding-specific advertised listener to be automatically applied to lookup request.

Proposed Solution
Enhance the broker to check for an empty string in the advertisedListenerName field. (code)

@michaeljmarshall
Copy link
Member

if (StringUtils.isNotBlank(listenerName)) {
lookup.setAdvertisedListenerName(listenerName);
}

@EronWright - were you able to reproduce this issue with the Java client? Based on the code you reference, it looks like the advertisedListenerName would be null unless a "non blank" string is used.

I can see in the Go client, we are using string type instead of a string reference (*string) type in the lookupService struct, and that results in passing an empty string.

I agree with your proposed solution, but I am concerned that this is a point of ambiguity in the spec that should be better defined. I'd also like to understand how we're seeing this issue with the Java client since it looks like it hasAdvertisedListenerName should return false in the ServerCnx.

@EronWright
Copy link
Contributor Author

@michaeljmarshall thanks for the review. I believe that hasAdvertisedListenerName would return true for any value, including null.

I'm trying to write a test into ServerCnxTest, may be challenging, stand by.

@michaeljmarshall
Copy link
Member

I believe that hasAdvertisedListenerName would return true for any value, including null.

I don't believe this is correct. If you look at the protobuf field definition, the advertised_listener_name field is an optional string.

optional string advertised_listener_name = 7;

I just ran a quick test to double check my understanding, and this test passes:

    @Test
    public void testAdvertisedListenerName() {
        BaseCommand bc1 = new BaseCommand();
        bc1.setLookupTopic();
        assertFalse(bc1.getLookupTopic().hasAdvertisedListenerName());

        try {
            bc1.setLookupTopic().setAdvertisedListenerName(null);
            fail();
        } catch (NullPointerException e) {
            // expected
        }

        BaseCommand bc2 = new BaseCommand();
        bc2.setLookupTopic().setAdvertisedListenerName("");
        assertTrue(bc2.getLookupTopic().hasAdvertisedListenerName());
    }

@merlimat
Copy link
Contributor

It will return true if the field is set. That is irrespective of the specific value that was set.

BewareMyPower pushed a commit that referenced this issue Feb 16, 2022
Fixes #14304

### Modifications

- [ServerCnx] check for blank advertised listener name
- [ServerCnx] improved logging
@EronWright
Copy link
Contributor Author

@BewareMyPower please cherry-pick this fix to 2.9, thanks.

BewareMyPower pushed a commit that referenced this issue Feb 17, 2022
Fixes #14304

### Modifications

- [ServerCnx] check for blank advertised listener name
- [ServerCnx] improved logging

(cherry picked from commit 422efbb)
@BewareMyPower
Copy link
Contributor

done.

Nicklee007 pushed a commit to Nicklee007/pulsar that referenced this issue Apr 20, 2022
Fixes apache#14304

### Modifications

- [ServerCnx] check for blank advertised listener name
- [ServerCnx] improved logging
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

Successfully merging a pull request may close this issue.

4 participants