Skip to content

Commit 79ec204

Browse files
committed
Add null protection for projects that do not have a support policy
1 parent 89610f6 commit 79ec204

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/java/io/spring/projectapi/github/GithubOperations.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ public List<Project> getProjects() {
283283

284284
public Project getProject(String projectSlug) {
285285
ResponseEntity<Map<String, Object>> response = getFile(projectSlug, "index.md");
286+
if (response == null) {
287+
return null;
288+
}
286289
String contents = getFileContents(response);
287290
Map<String, String> frontMatter = MarkdownUtils.getFrontMatter(contents);
288291
InvalidGithubProjectIndexException.throwIfInvalid(Objects::nonNull, frontMatter, projectSlug);
@@ -305,7 +308,6 @@ public List<ProjectSupport> getProjectSupports(String projectSlug) {
305308
return Collections.emptyList();
306309
}
307310
String contents = getFileContents(response);
308-
getProjectSupportPolicy(projectSlug);
309311
return List.copyOf(readValue(contents, SUPPORT_LIST));
310312
}
311313

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

332335
}

0 commit comments

Comments
 (0)