Skip to content

Commit

Permalink
fix some npe
Browse files Browse the repository at this point in the history
  • Loading branch information
dernasherbrezon committed Jan 20, 2024
1 parent 1bcc521 commit 3ea26b1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/main/java/ru/r2cloud/device/SdrServerDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public void reCalculateFrequencyBands(List<Transmitter> scheduledTransmitters) {

List<BandFrequency> bandwidths = new ArrayList<>();
for (Transmitter curTransmitter : scheduledTransmitters) {
if (curTransmitter.getBaudRates().isEmpty()) {
continue;
}
Integer maxBaudRate = Collections.max(curTransmitter.getBaudRates());
if (maxBaudRate == null) {
continue;
Expand Down Expand Up @@ -96,7 +99,9 @@ public void reCalculateFrequencyBands(List<Transmitter> scheduledTransmitters) {
}
currentBandTransmitters.add(cur.getTransmitter());
}
transmittersPerBand.put(currentBand, currentBandTransmitters);
if (currentBand != null) {
transmittersPerBand.put(currentBand, currentBandTransmitters);
}
LOG.info("[{}] active bands are:", id);
for (Entry<BandFrequency, List<Transmitter>> cur : transmittersPerBand.entrySet()) {
LOG.info(" {} - {}", cur.getKey().getLower(), cur.getKey().getUpper());
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/ru/r2cloud/model/Transmitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;
import java.util.Base64;
import java.util.Collections;
import java.util.Date;
import java.util.List;

Expand Down Expand Up @@ -91,19 +92,19 @@ public Transmitter(Transmitter copy) {
this.updated = new Date(copy.updated.getTime());
}
}

public int getPriorityIndex() {
return priorityIndex;
}

public void setPriorityIndex(int priorityIndex) {
this.priorityIndex = priorityIndex;
}

public long getFrequencyBand() {
return frequencyBand;
}

public void setFrequencyBand(long frequencyBand) {
this.frequencyBand = frequencyBand;
}
Expand Down Expand Up @@ -369,6 +370,8 @@ public static Transmitter fromJson(JsonObject asObject) {
bauds.add(baudRatesArray.get(i).asInt());
}
result.setBaudRates(bauds);
} else {
result.setBaudRates(Collections.emptyList());
}
JsonValue modulation = asObject.get("modulation");
if (modulation != null) {
Expand Down

0 comments on commit 3ea26b1

Please sign in to comment.