google-code-export / openhab

Automatically exported from code.google.com/p/openhab
GNU General Public License v3.0
0 stars 0 forks source link

NullpointerException in org.io.transport.mqtt #509

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. using mqtt binding to connect two OpenHAB instances

What is the expected output? What do you see instead?

java.lang.NullPointerException: null
        at org.openhab.io.transport.mqtt.internal.MqttBrokerConnection.deliveryComplete(MqttBrokerConnection.java:529)

leading to Mqtt transport reconnecting after each message

What version of the product are you using? On what operating system?

1.4.0 on Debian/wheezy

Please provide any additional information below.

Patch (org.io.transport.mqtt bundle):

$ diff -u 
src/main/java/org/openhab/io/transport/mqtt/internal/MqttBrokerConnection.java{,
.orig}
--- 
src/main/java/org/openhab/io/transport/mqtt/internal/MqttBrokerConnection.java  2
013-11-07 17:29:57.189675335 +0100
+++ 
src/main/java/org/openhab/io/transport/mqtt/internal/MqttBrokerConnection.java.o
rig 2013-11-07 17:27:31.614483164 +0100
@@ -526,11 +526,7 @@
    @Override
    public void deliveryComplete(IMqttDeliveryToken token) {
        try {
-           String message;
-           if( token == null ) message = "null token";
-             else if( token.getMessage() == null ) message = "null message";
-             else message = "" + token.getMessage().getPayload();
-           logger.trace("Delivery completed for message : '{}'", message );
+           logger.trace("Delivery completed for message : '{}'", new 
String(token.getMessage().getPayload()));
        } catch (MqttException e) {
            logger.error("Error loggin message delivery result", e);
        }

Obviously, getMessage() returns null ...

Original issue reported on code.google.com by taeom...@gmail.com on 7 Nov 2013 at 5:03

GoogleCodeExporter commented 9 years ago

Original comment by kai.openhab on 7 Nov 2013 at 5:07

GoogleCodeExporter commented 9 years ago
Thanks for the detailed info and proposed patch.
A fix for the nullpointer has been merged into the main repo. It should be 
available in the next nightly build.

Original comment by davy.van...@gmail.com on 7 Nov 2013 at 8:43