[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [paho-dev] Calling isConnected in MqttAndroidClient soon after initialization causes NPE
|
Hi,
This NPE issue should be already fixed in https://bugs.eclipse.org/bugs/show_bug.cgi?id=444318
Best Regards,
Bin Zhang(张斌)
--------------------------------------------------------------------------------------------
WebSphere MQ, IBM China Software Development Lab
Notes: Bin BJ Zhang/China/IBM
E-Mail: zhbinbj@xxxxxxxxxx
Address: Ring Building 3F, ZhongGuanCun Software Park,
DongBeiWang West Road No.8, Haidian District, Beijing, 100193, China
-------------------------------------------------------------------------------------------
Ranhiru Cooray ---12/02/2014 07:07:19 PM---Hello everyone! I am calling
From: Ranhiru Cooray <ranhiru@xxxxxxxxx>
To: paho-dev@xxxxxxxxxxx
Date: 12/02/2014 07:07 PM
Subject: [paho-dev] Calling isConnected in MqttAndroidClient soon after initialization causes NPE
Sent by: paho-dev-bounces@xxxxxxxxxxx
Hello everyone!
I am calling
client = new MqttAndroidClient(context, "tcp://192.168.123.177:1883", "XXXX");
and then soon after I call my method connectToMqttServer() which checks if (!client.isConnected()) before attempting to connect.
Going through the source code I see that isConnected is implemented as follows.
public boolean isConnected() {
mqttService.isConnected(clientHandle);
}
However because I haven't called connect, mqttService will be null and it will thrown a NullPointerException.
I changed it as follows.
return mqttService != null && mqttService.isConnected(clientHandle);
Are there any potential pitfalls in doing this ? Is this the correct way ?
I personally think that it's natural to call isConnected() before calling connect()
Any ideas/comments would be appreciated.
Thanks!
Ranhiru
_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/paho-dev
