Skip to content

Commit 3b1a166

Browse files
committed
Added Further Null Checks To Prevent Potential Runtime Exceptions
1 parent 2d85675 commit 3b1a166

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

Diff for: MekHQ/src/mekhq/MekHQ.java

+23-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import java.io.ObjectInputFilter.Config;
4141
import java.lang.management.ManagementFactory;
4242
import java.util.List;
43+
import java.util.Map;
4344
import java.util.UUID;
4445
import javax.swing.InputMap;
4546
import javax.swing.JOptionPane;
@@ -784,8 +785,23 @@ public void autoResolveConcluded(AutoResolveConcludedEvent autoResolveConcludedE
784785
true,
785786
tracker);
786787
resolveDialog.setVisible(true);
788+
// TODO remove these safeties as they're shown to be unnecessary
789+
if (resolveDialog == null) {
790+
throw new IllegalStateException("resolveDialog is null");
791+
}
787792
if (resolveDialog.wasAborted()) {
793+
// TODO remove these safeties as they're shown to be unnecessary
794+
Map<UUID, ?> peopleStatus = tracker.getPeopleStatus();
795+
if (peopleStatus == null) {
796+
throw new IllegalStateException("People status map in tracker is null");
797+
}
798+
788799
for (UUID personId : tracker.getPeopleStatus().keySet()) {
800+
// TODO remove these safeties as they're shown to be unnecessary
801+
if (getCampaign() == null) {
802+
throw new IllegalStateException("Campaign instance is null");
803+
}
804+
789805
Person person = getCampaign().getPerson(personId);
790806

791807
if (person == null) {
@@ -794,7 +810,13 @@ public void autoResolveConcluded(AutoResolveConcludedEvent autoResolveConcludedE
794810
" does not exist in the campaign");
795811
}
796812

797-
person.setHits(person.getHitsPrior());
813+
Integer priorHits = person.getHitsPrior();
814+
// TODO remove these safeties as they're shown to be unnecessary
815+
if (priorHits == null) {
816+
throw new IllegalStateException("Person's prior hits are not set for person " +
817+
person.getFullName());
818+
}
819+
person.setHits(priorHits);
798820
}
799821
return;
800822
}

0 commit comments

Comments
 (0)