[HTTP] Add java.lang.NullPointerException to catch while parsing json
Probably after updating jenkins/groovy that JsonSlurperClassic() also
fixed/changed something and now when it tries to parse output like
'127.0.0.1' or event just a single number it throws
java.lang.NullPointerException exception and it breaks flow of
sendHttpRequest() function.
Related-To: PRODX-10294
Change-Id: Ia9ec379256771f1384fd3f57c5e31d9ce27bae56
diff --git a/src/com/mirantis/mk/Http.groovy b/src/com/mirantis/mk/Http.groovy
index b752b42..a7e0f97 100644
--- a/src/com/mirantis/mk/Http.groovy
+++ b/src/com/mirantis/mk/Http.groovy
@@ -55,7 +55,10 @@
response = connection.inputStream.text
try {
response_content = new groovy.json.JsonSlurperClassic().parseText(response)
- } catch (groovy.json.JsonException e) {
+ } catch (groovy.json.JsonException|java.lang.NullPointerException e) {
+ if(env.getEnvironment().containsKey('DEBUG') && env['DEBUG'] == "true"){
+ println("[HTTP] Cought exception while trying parsing response as JSON: ${e}")
+ }
response_content = response
}
if(env.getEnvironment().containsKey('DEBUG') && env['DEBUG'] == "true"){