Skip to content

Commit

Permalink
Fix NPE when getting model config lists (#4017)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
kbirk and github-actions[bot] authored Jul 2, 2024
1 parent 3ef9512 commit fe0c2fa
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ public Model clone() {
@JsonIgnore
@TSIgnore
public List<Observable> getObservables() {
if (this.getSemantics() == null || this.getSemantics().getOde() == null) {
if (this.getSemantics() == null
|| this.getSemantics().getOde() == null
|| this.getSemantics().getOde().getObservables() == null) {
return new ArrayList<Observable>();
}
return this.getSemantics().getOde().getObservables();
Expand All @@ -111,12 +113,13 @@ public List<ModelParameter> getParameters() {
final ObjectMapper objectMapper = new ObjectMapper();
if (this.isRegnet()) {
return objectMapper.convertValue(this.getModel().get("parameters"), new TypeReference<>() {});
} else {
if (this.getSemantics() == null || this.getSemantics().getOde() == null) {
return new ArrayList<ModelParameter>();
}
return this.getSemantics().getOde().getParameters();
}
if (this.getSemantics() == null
|| this.getSemantics().getOde() == null
|| this.getSemantics().getOde().getParameters() == null) {
return new ArrayList<ModelParameter>();
}
return this.getSemantics().getOde().getParameters();
}

@JsonIgnore
Expand All @@ -126,7 +129,9 @@ public List<Initial> getInitials() {
if (this.isRegnet()) {
return objectMapper.convertValue(this.getModel().get("initials"), new TypeReference<>() {});
} else {
if (this.getSemantics() == null || this.getSemantics().getOde() == null) {
if (this.getSemantics() == null
|| this.getSemantics().getOde() == null
|| this.getSemantics().getOde().getInitials() == null) {
return new ArrayList<Initial>();
}
return this.getSemantics().getOde().getInitials();
Expand Down

0 comments on commit fe0c2fa

Please sign in to comment.