tbsalling / aismessages

AISmessages is a Java-based light-weight, zero-dependency, and ultra-efficient message decoder for maritime navigation and safety messages compliant with ITU 1371 (NMEA armoured AIS messages). A live demo of AISmessages is available on http://ais.tbsalling.dk.
https://github.com/tbsalling/aismessages/wiki
Other
156 stars 66 forks source link

NPE #34

Closed z2z2qp closed 4 years ago

z2z2qp commented 4 years ago

在 AISMessage.java 方法 decodePayloadToBitString 会调用 NMEAMessage.java 内的 方法getFillBits可能出现空指针异常

` protected static String decodePayloadToBitString(NMEAMessage... nmeaMessages) { StringBuilder sixBitEncodedPayload = new StringBuilder(); int fillBits = -1; for (int i = 0; i < nmeaMessages.length; i++) { NMEAMessage m = nmeaMessages[i]; sixBitEncodedPayload.append(m.getEncodedPayload()); if (i == nmeaMessages.length - 1) { fillBits = m.getFillBits();//may be throw NPE } }

    // The AIS message payload stored as a string of 0's and 1's
    return toBitString(sixBitEncodedPayload.toString(), fillBits);
}

`

tbsalling commented 4 years ago

Hi @z2z2qp - can you provide a unit test with decoding of an NMEA-armored AIS messages that fails? Then I will look into it.

z2z2qp commented 4 years ago

我发现不止这一处会报空指针(I've also found that other places may be NPE.) like this NMEAMessageHandler.java
line 66 int numberOfFragments = nmeaMessage.getNumberOfFragments(); “nmeaMessage.getNumberOfFragments()” may be retrun null

line 76 int fragmentNumber = nmeaMessage.getFragmentNumber(); “nmeaMessage.getFragmentNumber()” may be retrun null

我给你邮箱 tbsalling@tbsalling.dk 发了个邮件,有测试的 TCP service

michaeljfazio commented 4 years ago

I seemed to have hit this one pretty quickly as well. I believe it has to do with serialisation/deserialisation of bitString value in AISMessage which is transient. In our case, we are evaluating the use of this library ontop of Flink/Hadoop etc. And because of the transient member variables, any time an AISMessage is serialised (e.g. when being passed between nodes), it will fail -- because the transient variable will be null upon deserialisation.

A show stopper if you want to use this library in any system that implements distributed processing.

tbsalling commented 4 years ago

@michaeljfazio (or @z2z2qp) is it possible that you could provide me with a unit test that demonstrates the exact problem? It makes it a lot easier for me to find a way to support you.

tbsalling commented 4 years ago

Closed due to lack of activity.