catch NullPointerException instead of checking for null

This commit is contained in:
technillogue 2021-07-21 15:35:26 -04:00
parent 72e89cd0fc
commit 17ccb20507

View file

@ -67,17 +67,13 @@ public class JsonMessageEnvelope {
this.sourceDevice = null; this.sourceDevice = null;
this.relay = null; this.relay = null;
} }
if (this.source != null) { String name;
String name; try {
try { name = m.getContactOrProfileName(this.source);
name = m.getContactOrProfileName(this.source); } catch (InvalidNumberException | NullPointerException e) {
} catch (InvalidNumberException e) { name = null;
name = null;
}
this.sourceName = name;
} else {
this.sourceName = null;
} }
this.sourceName = name;
this.timestamp = envelope.getTimestamp(); this.timestamp = envelope.getTimestamp();
if (envelope.isReceipt()) { if (envelope.isReceipt()) {
this.receiptMessage = JsonReceiptMessage.deliveryReceipt(timestamp, List.of(timestamp)); this.receiptMessage = JsonReceiptMessage.deliveryReceipt(timestamp, List.of(timestamp));