From 1a58b70a8eb1dd0e9c82e2242452b9300ae973eb Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 7 Apr 2016 06:23:43 -0800 Subject: [PATCH] Github API fix. --- .../kotlin/com/beust/kobalt/misc/GithubApi2.kt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/GithubApi2.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/GithubApi2.kt index 32b8bfb8..8fd571e3 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/GithubApi2.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/GithubApi2.kt @@ -117,14 +117,17 @@ class GithubApi2 @Inject constructor( } else { service.getReleasesNoAuth("cbeust", "kobalt") } - val releases = req.execute() - .body() - releases.firstOrNull()?.let { - try { - result = listOf(it.name, it.tagName).filterNotNull().first { !it.isBlank() } - } catch(ex: NoSuchElementException) { - throw KobaltException("Couldn't find the latest release") + val releases = req.execute().body() + if (releases != null) { + releases.firstOrNull()?.let { + try { + result = listOf(it.name, it.tagName).filterNotNull().first { !it.isBlank() } + } catch(ex: NoSuchElementException) { + throw KobaltException("Couldn't find the latest release") + } } + } else { + warn("Didn't receive any body in the response to GitHub.getReleases()") } } catch(e: Exception) { log(1, "Couldn't retrieve releases from github: " + e.message)