Skip to content

Commit

Permalink
fix null pointer exception on invalid DF packet
Browse files Browse the repository at this point in the history
  • Loading branch information
filipjonckers committed Jan 7, 2022
1 parent e2abf2f commit 9a1b9bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GROUP=aero.t2s
VERSION_NAME=0.2.3-SNAPSHOT
VERSION_NAME=0.2.4-SNAPSHOT

POM_ARTIFACT_ID=mode-s
POM_NAME=Mode-S/ADS-B (1090Mhz)
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/aero/t2s/modes/ModeSTrackHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public void handle(final String input) {
public DownlinkFormat handleSync(final String input) {
try {
DownlinkFormat df = decoder.decode(toData(input));
if(df == null) {
// invalid packet (Mode A/C like *21D2; *0200; *0101;)
LOGGER.debug("DF Message could not be parsed: [{}]", input);
return null;
}

Track track = decoder.getTrack(df.getIcao());

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

return null;
Expand Down

0 comments on commit 9a1b9bf

Please sign in to comment.