eclipse / paho.mqtt.java

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

MqttProperties.toString() throws NullPointerException #472

Closed borgendale closed 6 years ago

borgendale commented 6 years ago

Please fill out the form below before submitting, thank you!

If this is a bug regarding the Android Service, please raise the bug here instead: https://github.com/eclipse/paho.mqtt.android/issues/new

When running the 20180113.052500-18 build

test.java: import org.eclipse.paho.mqttv5.common.packet.MqttProperties; public class test { public static void main (String[] args) { MqttProperties props = new MqttProperties(); System.out.println("empty props = " + props); } } Exception in thread "main" java.lang.NullPointerException at org.eclipse.paho.mqttv5.common.packet.MqttProperties.toString(MqttProperties.java:1320) at java.lang.String.valueOf(String.java:1862) at java.lang.StringBuilder.append(StringBuilder.java:218) at test.main(test.java:5)

This problem occurs in several other places in this method. For Boolean properties the code does not check the object for null but checks the boolean value which fails when the variable is null.

jpwsutton commented 6 years ago

Hi @borgendale, Sorry for the break, I accidentially pushed some half baked code a week or two back and didn't notice. The fix for this was in commit d083428 which is now in the latest snapshot version, note that because I've now brought the v5 library into the develop branch, it's building at the same version as everything else now which means that it is now in the 1.2.1-SNAPSHOT directory (https://repo.eclipse.org/content/repositories/paho-snapshots/org/eclipse/paho/org.eclipse.paho.mqttv5.client/1.2.1-SNAPSHOT/)