diff --git a/org.eclipse.paho.mqttv5.client/src/main/java/org/eclipse/paho/mqttv5/client/MqttClient.java b/org.eclipse.paho.mqttv5.client/src/main/java/org/eclipse/paho/mqttv5/client/MqttClient.java index 2fb731edb..911d0e4ab 100644 --- a/org.eclipse.paho.mqttv5.client/src/main/java/org/eclipse/paho/mqttv5/client/MqttClient.java +++ b/org.eclipse.paho.mqttv5.client/src/main/java/org/eclipse/paho/mqttv5/client/MqttClient.java @@ -522,7 +522,16 @@ public IMqttToken subscribe(String topicFilter, int qos, IMqttMessageListener me public IMqttToken subscribe(String[] topicFilters, int[] qos, IMqttMessageListener[] messageListeners) throws MqttException { - return this.subscribe(topicFilters, qos, messageListeners); + if (topicFilters.length != qos.length) { + throw new MqttException(MqttClientException.REASON_CODE_UNEXPECTED_ERROR); + } + + MqttSubscription[] subscriptions = new MqttSubscription[topicFilters.length]; + for (int i = 0; i < topicFilters.length; ++i) { + subscriptions[i] = new MqttSubscription(topicFilters[i], qos[i]); + } + + return this.subscribe(subscriptions, messageListeners); } public IMqttToken subscribe(MqttSubscription[] subscriptions, IMqttMessageListener[] messageListeners) throws MqttException {