eclipse-paho / paho.mqtt.java

Eclipse Paho Java MQTT client library. Paho is an Eclipse IoT project.
https://eclipse.org/paho
Other
2.15k stars 893 forks source link

bug in subscribe method(MqttClient.java) #512

Closed rasoulinejad closed 5 years ago

rasoulinejad commented 6 years ago

java.lang.ArrayIndexOutOfBoundsException: length=1; index=1 at org.eclipse.paho.client.mqttv3.MqttClient.subscribe(MqttClient.java:435) at org.eclipse.paho.client.mqttv3.MqttClient.subscribe(MqttClient.java:424)

public void subscribe(String[] topicFilters, int[] qos) throws MqttException { IMqttToken tok = this.aClient.subscribe(topicFilters, qos, (Object)null, (IMqttActionListener)null); tok.waitForCompletion(this.getTimeToWait()); int[] grantedQos = tok.getGrantedQos(); for(int i = 0; i < grantedQos.length; ++i) { qos[i] = grantedQos[i] ; // *** this line cause exception **** } if(grantedQos.length == 1 && qos[0] == 128) { throw new MqttException(128); } }

jpwsutton commented 6 years ago

Hi, before we can look at this, please could you fill provide us with the following information:

From the issue template, please let us know which client this bug is from:

Could you clarify if possible, the arguments that you are calling subscribe with please? Are you seeing any other errors?

rasoulinejad commented 6 years ago

Bug exists Release Version 1.2.0 ( Master Branch)

qos[i] = grantedQos[i] ; // *** this line cause exception ****

icraggs commented 5 years ago

We would need more information on the circumstances that caused this error. Thanks.