Skip to content

Commit

Permalink
Add null protection for projects that do not have a support policy
Browse files Browse the repository at this point in the history
  • Loading branch information
mbhave committed Nov 6, 2024
1 parent 89610f6 commit 79ec204
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ public List<Project> getProjects() {

public Project getProject(String projectSlug) {
ResponseEntity<Map<String, Object>> response = getFile(projectSlug, "index.md");
if (response == null) {
return null;
}
String contents = getFileContents(response);
Map<String, String> frontMatter = MarkdownUtils.getFrontMatter(contents);
InvalidGithubProjectIndexException.throwIfInvalid(Objects::nonNull, frontMatter, projectSlug);
Expand All @@ -305,7 +308,6 @@ public List<ProjectSupport> getProjectSupports(String projectSlug) {
return Collections.emptyList();
}
String contents = getFileContents(response);
getProjectSupportPolicy(projectSlug);
return List.copyOf(readValue(contents, SUPPORT_LIST));
}

Expand All @@ -326,7 +328,8 @@ public String getProjectSupportPolicy(String projectSlug) {
String indexContents = getFileContents(indexResponse);
Map<String, String> frontMatter = MarkdownUtils.getFrontMatter(indexContents);
InvalidGithubProjectIndexException.throwIfInvalid(Objects::nonNull, frontMatter, projectSlug);
return frontMatter.get("supportPolicy");
String supportPolicy = frontMatter.get("supportPolicy");
return (supportPolicy != null) ? supportPolicy : DEFAULT_SUPPORT_POLICY;
}

}

0 comments on commit 79ec204

Please sign in to comment.