Skip to content

Commit 9a1b9bf

Browse files
committed
fix null pointer exception on invalid DF packet
1 parent e2abf2f commit 9a1b9bf

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
GROUP=aero.t2s
2-
VERSION_NAME=0.2.3-SNAPSHOT
2+
VERSION_NAME=0.2.4-SNAPSHOT
33

44
POM_ARTIFACT_ID=mode-s
55
POM_NAME=Mode-S/ADS-B (1090Mhz)

src/main/java/aero/t2s/modes/ModeSTrackHandler.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ public void handle(final String input) {
5959
public DownlinkFormat handleSync(final String input) {
6060
try {
6161
DownlinkFormat df = decoder.decode(toData(input));
62+
if(df == null) {
63+
// invalid packet (Mode A/C like *21D2; *0200; *0101;)
64+
LOGGER.debug("DF Message could not be parsed: [{}]", input);
65+
return null;
66+
}
67+
6268
Track track = decoder.getTrack(df.getIcao());
6369

6470
if (track == null) {
@@ -83,7 +89,7 @@ public DownlinkFormat handleSync(final String input) {
8389
} catch (InvalidExtendedSquitterTypeCodeException | UnknownDownlinkFormatException e) {
8490
LOGGER.error(e.getMessage());
8591
} catch (Throwable throwable) {
86-
LOGGER.error("Message could not be parsed: [" + input + "]", throwable);
92+
LOGGER.error("DF Message could not be parsed: [" + input + "]", throwable);
8793
}
8894

8995
return null;

0 commit comments

Comments
 (0)