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

Stack Overflow when using Topicfilter with a large number of levels. #334

Closed
sauroter opened this issue Sep 27, 2019 · 0 comments · Fixed by #338
Closed

Stack Overflow when using Topicfilter with a large number of levels. #334

sauroter opened this issue Sep 27, 2019 · 0 comments · Fixed by #338
Assignees
Labels
Milestone

Comments

@sauroter
Copy link
Member

sauroter commented Sep 27, 2019

Expected behavior

Client handles subscriptions with a large amount of topic levels gracefully.

Actual behavior

java.lang.StackOverflowError in com.hivemq.client.internal.mqtt.handler.subscribe.MqttSubscriptionHandler.

To Reproduce

Steps

  1. Set up a MQTT broker on localhost.
  2. Run reproducer code.

Reproducer code

public class Main {

    public static void main(String[] args) {

        final Mqtt5BlockingClient client = MqttClient.builder()
                .identifier(UUID.randomUUID().toString())
                .serverHost("localhost")
                .useMqttVersion5()
                .build().toBlocking();

        client.connect();

        final StringBuilder basis = new StringBuilder("/");

        for (int i = 0; i < 16; i++) {
            final String string = basis.toString();
            System.err.println("Rotation: " + i + " StringSize=" + string.length());
            final MqttTopicFilter filter = MqttTopicFilter.of(string);
            client.subscribeWith().topicFilter(filter).send();
            client.unsubscribeWith().addTopicFilter(filter).send();
            basis.append(basis);
        }
    }
}

Details

  • Affected HiveMQ MQTT Client version(s):
        <dependency>
            <groupId>com.hivemq</groupId>
            <artifactId>hivemq-mqtt-client</artifactId>
            <version>1.1.2</version>
        </dependency>
  • Used JVM version:
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.4+11)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.4+11, mixed mode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants