3535import io .spring .projectapi .github .ProjectDocumentation .Status ;
3636import org .apache .maven .artifact .versioning .ComparableVersion ;
3737import org .jetbrains .annotations .NotNull ;
38+ import org .slf4j .Logger ;
39+ import org .slf4j .LoggerFactory ;
3840
3941import org .springframework .boot .web .client .RestTemplateBuilder ;
4042import org .springframework .cache .annotation .Cacheable ;
@@ -64,6 +66,8 @@ public class GithubOperations {
6466
6567 private static final Comparator <ProjectDocumentation > VERSION_COMPARATOR = GithubOperations ::compare ;
6668
69+ private static final Logger logger = LoggerFactory .getLogger (GithubOperations .class );
70+
6771 private final RestTemplate restTemplate ;
6872
6973 private final ObjectMapper objectMapper ;
@@ -74,6 +78,8 @@ public class GithubOperations {
7478
7579 private static final String CONFIG_COMMIT_MESSAGE = "Update Spring Boot Config" ;
7680
81+ private static final String DEFAULT_SUPPORT_POLICY = "UPSTREAM" ;
82+
7783 private static final ParameterizedTypeReference <Map <String , Object >> STRING_OBJECT_MAP = new ParameterizedTypeReference <>() {
7884 };
7985
@@ -212,6 +218,8 @@ private ResponseEntity<Map<String, Object>> getFile(String projectSlug, String f
212218 return this .restTemplate .exchange (request , STRING_OBJECT_MAP );
213219 }
214220 catch (HttpClientErrorException ex ) {
221+ logger .info ("*** Exception thrown for " + projectSlug + " and file " + fileName + " due to "
222+ + ex .getMessage () + " with status " + ex .getStatusCode ());
215223 HttpStatusCode statusCode = ex .getStatusCode ();
216224 if (statusCode .value () == 404 ) {
217225 throwIfProjectDoesNotExist (projectSlug );
@@ -257,7 +265,10 @@ public List<Project> getProjects() {
257265 body .forEach ((project ) -> {
258266 String projectSlug = (String ) project .get ("name" );
259267 try {
260- projects .add (getProject (projectSlug ));
268+ Project fetchedProject = getProject (projectSlug );
269+ if (fetchedProject != null ) {
270+ projects .add (fetchedProject );
271+ }
261272 }
262273 catch (Exception ex ) {
263274 // Ignore project without an index file
@@ -281,6 +292,9 @@ public Project getProject(String projectSlug) {
281292
282293 public List <ProjectDocumentation > getProjectDocumentations (String projectSlug ) {
283294 ResponseEntity <Map <String , Object >> response = getFile (projectSlug , "documentation.json" );
295+ if (response == null ) {
296+ return Collections .emptyList ();
297+ }
284298 String content = getFileContents (response );
285299 return List .copyOf (convertToProjectDocumentation (content ));
286300 }
@@ -304,9 +318,11 @@ private <T> T readValue(String contents, TypeReference<T> type) {
304318 }
305319 }
306320
307- @ Cacheable (value = "support_policy" , key = "#projectSlug" )
308321 public String getProjectSupportPolicy (String projectSlug ) {
309322 ResponseEntity <Map <String , Object >> indexResponse = getFile (projectSlug , "index.md" );
323+ if (indexResponse == null ) {
324+ return DEFAULT_SUPPORT_POLICY ;
325+ }
310326 String indexContents = getFileContents (indexResponse );
311327 Map <String , String > frontMatter = MarkdownUtils .getFrontMatter (indexContents );
312328 InvalidGithubProjectIndexException .throwIfInvalid (Objects ::nonNull , frontMatter , projectSlug );
0 commit comments