Skip to content

Commit

Permalink
fix(mine): handle exceptions when error response body is null in Regi…
Browse files Browse the repository at this point in the history
…sterCanaryTask

Before this change the RetrofitError catch block would throw a NullPointerException when error response body is null at line no: https://github.com/spinnaker/orca/blob/613427f41bb16461a7ee8bb0f31212b438d75458/orca-mine/src/main/groovy/com/netflix/spinnaker/orca/mine/tasks/RegisterCanaryTask.groovy#L70

Here is the exact stack trace : java.lang.NullPointerException: Cannot set property 'status' on null object
	at org.codehaus.groovy.runtime.NullObject.setProperty(NullObject.java:80)
	at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:213)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:496)
	at com.netflix.spinnaker.orca.mine.tasks.RegisterCanaryTask.execute(RegisterCanaryTask.groovy:70)
  • Loading branch information
Pranav-b-7 committed Mar 23, 2024
1 parent e79fcd9 commit 4dc0667
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class RegisterCanaryTask implements Task {
} catch (RetrofitError re) {
def response = [:]
try {
response = re.getBodyAs(Map) as Map
def responseBody = re.getBodyAs(Map) as Map
response = responseBody!=null ? responseBody : response
} catch (Exception e) {
response.error = e.message
}
Expand Down

0 comments on commit 4dc0667

Please sign in to comment.