Skip to content

Commit 77a1263

Browse files
committed
mra/importers/sdf/SdfParser: Prevention of NPE when a plan has gapped sidescan.
1 parent 7826510 commit 77a1263

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

src/java/pt/lsts/neptus/mra/importers/sdf/SdfParser.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -545,23 +545,23 @@ else if (subsystem == SUBSYS_HIGH)
545545
return ping;
546546
}
547547

548-
private void redirectIndex(Long timestamp, int subsystem) {
548+
private boolean redirectIndex(Long timestamp, int subsystem) {
549549
for (Entry<File, SdfIndex> entry : fileIndex.entrySet()) {
550550
if (subsystem == SUBSYS_LOW) {
551551
if (timestamp >= entry.getValue().firstTimestampLow && timestamp <= entry.getValue().lastTimestampLow) {
552552
index = entry.getValue();
553553
file = entry.getKey();
554-
return;
554+
return true;
555555
}
556-
} else
557-
if (subsystem == SUBSYS_HIGH) {
558-
if (timestamp >= entry.getValue().firstTimestampHigh && timestamp <= entry.getValue().lastTimestampHigh) {
559-
index = entry.getValue();
560-
file = entry.getKey();
561-
return;
562-
}
556+
} else if (subsystem == SUBSYS_HIGH) {
557+
if (timestamp >= entry.getValue().firstTimestampHigh && timestamp <= entry.getValue().lastTimestampHigh) {
558+
index = entry.getValue();
559+
file = entry.getKey();
560+
return true;
563561
}
562+
}
564563
}
564+
return false;
565565
}
566566

567567
private boolean existsTimestamp(long timestamp, SdfIndex searchIndex) {
@@ -573,10 +573,17 @@ private boolean existsTimestamp(long timestamp, SdfIndex searchIndex) {
573573

574574
public SdfData getPingAt(Long timestamp, int subsystem) {
575575

576+
if (index == null) {
577+
return null;
578+
}
579+
576580
// point index to right index_ file according to timestamp
577-
if (index != null && multipleFiles) {
581+
if (multipleFiles) {
578582
if (!existsTimestamp(timestamp, index)) {
579-
redirectIndex(timestamp, subsystem);
583+
boolean reg = redirectIndex(timestamp, subsystem);
584+
if (!reg) {
585+
return null;
586+
}
580587
}
581588
}
582589
// end

0 commit comments

Comments
 (0)