Skip to content

Commit 5a2c23e

Browse files
Fernandohannesa2
Fernando
authored andcommitted
Subscribe should not return null (#262)
Always returning null breaks the contract set in the function signature and documentation. This affects all subscribes that receive `IMqttMessageListener` as parameter. Signed-off-by: Fernando Governatore <[email protected]> Should pass IMqttActionListener on subscribe (#262) On subscribe, a failure would be reported but onSuccess would never be called. The reason was not passing the IMqttActionListener forward to MqttClient. Signed-off-by: Fernando Governatore <[email protected]>
1 parent 3c3f2a0 commit 5a2c23e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

org.eclipse.paho.android.service/src/main/java/org/eclipse/paho/android/service/MqttAndroidClient.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ public IMqttToken subscribe(String[] topicFilters, int[] qos, Object userContext
962962
String activityToken = storeToken(token);
963963
mqttService.subscribe(clientHandle, topicFilters, qos, null, activityToken, messageListeners);
964964

965-
return null;
965+
return token;
966966
}
967967

968968
/**

org.eclipse.paho.android.service/src/main/java/org/eclipse/paho/android/service/MqttConnection.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ public void subscribe(String[] topicFilters, int[] qos, String invocationContext
588588
if ((myClient != null) && (myClient.isConnected())) {
589589
IMqttActionListener listener = new MqttConnectionListener(resultBundle);
590590
try {
591-
myClient.subscribe(topicFilters, qos, messageListeners);
591+
myClient.subscribe(topicFilters, qos, null, listener,messageListeners);
592592
} catch (Exception e) {
593593
handleException(resultBundle, e);
594594
}

0 commit comments

Comments
 (0)