diana4sb / xbee-api

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

NullPointerException in ErrorResponse.toString() created from an exception #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. run the example at 
http://code.google.com/p/xbee-api/source/browse/trunk/src/com/rapplogic/xbee/exa
mples/wpan/NodeDiscoverTest.java

2. Observe NullPointerException upon timeout expiration: 

java.lang.NullPointerException
    at com.rapplogic.xbee.api.XBeeResponse.toString(XBeeResponse.java:105)
    at com.rapplogic.xbee.api.ErrorResponse.toString(ErrorResponse.java:63)
    at java.lang.String.valueOf(String.java:2826)
    at java.lang.StringBuilder.append(StringBuilder.java:115)
    at net.sf.dz3.device.sensor.impl.xbee.XBeeDeviceFactory$1.processResponse(XBeeDeviceFactory.java:175)
    at com.rapplogic.xbee.api.XBee.handlePacket(XBee.java:284)
    at com.rapplogic.xbee.api.XBeePacketParser.newPacketNotification(XBeePacketParser.java:159)
    at com.rapplogic.xbee.api.XBeePacketParser.run(XBeePacketParser.java:121)
    at java.lang.Thread.run(Thread.java:619)

3.

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

Current SVN code, platform independent

Please provide any additional information below.

Patch below fixes the situation:

Index: src/com/rapplogic/xbee/api/XBeeResponse.java
===================================================================
--- src/com/rapplogic/xbee/api/XBeeResponse.java    (revision 216)
+++ src/com/rapplogic/xbee/api/XBeeResponse.java    (working copy)
@@ -102,7 +102,7 @@

    public String toString() {
        return "apiId=" + this.apiId +
-           ",length=" + length.get16BitValue() + 
+           ",length=" + (length == null ? "?" : length.get16BitValue()) + 
            ",checksum=" + ByteUtils.toBase16(checksum) +
            ",error=" + this.error;
    }

Original issue reported on code.google.com by vadim.tkachenko on 29 Jul 2010 at 4:13

GoogleCodeExporter commented 9 years ago
Scheduled for the next release

Original comment by andrew.rapp@gmail.com on 13 Aug 2010 at 3:16

GoogleCodeExporter commented 9 years ago
This has been fixed in the trunk.

Original comment by andrew.rapp@gmail.com on 20 Oct 2010 at 2:41