-
Notifications
You must be signed in to change notification settings - Fork 807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(clouddriver) : InstanceService - Eliminated the usages of RetrofitError exception handling and replaced it with SpinnakerRetrofitErrorHandler #4580
Conversation
6da5ea7
to
e1be772
Compare
d69e28b
to
662abe2
Compare
@@ -121,6 +122,7 @@ class JarDiffsTask implements DiffTask { | |||
RestAdapter restAdapter = new RestAdapter.Builder() | |||
.setEndpoint(address) | |||
.setClient(new OkClient(okHttpClient)) | |||
.setErrorHandler(SpinnakerRetrofitErrorHandler.getInstance()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised spotless doesn't complain about this.
.setErrorHandler(SpinnakerRetrofitErrorHandler.getInstance()) | |
.setErrorHandler(SpinnakerRetrofitErrorHandler.getInstance()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code formatted as per the suggestion.
...ouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/tasks/quip/AbstractQuipTask.groovy
Outdated
Show resolved
Hide resolved
@@ -103,7 +113,7 @@ class JarDiffsTaskSpec extends Specification { | |||
Response jarsResponse = new Response('http://foo.com', 200, 'OK', [], new TypedString(sourceJarsResponse)) | |||
|
|||
when: | |||
1 * instanceService.getJars() >> {throw new RetrofitError(null, null, null, null, null, null, null)} | |||
1 * instanceService.getJars() >> {throw new SpinnakerServerException(request)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be a smaller change to wrap the RetrofitError in a SpinnakerServerException since that's what SpinnakerRetrofitErrorHandler does. The exception handling here is simple enough that it probably doesn't matter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified the test cases to wrap the Spinnaker*Exception with RetrofitError
3cd6705
to
5d2d11e
Compare
...driver/src/test/groovy/com/netflix/spinnaker/orca/kato/tasks/quip/TriggerQuipTaskSpec.groovy
Outdated
Show resolved
Hide resolved
…ofitError in the catch blocks and added SpinnakerRetrofitErrorHandler in the retrofit config which handles the RetrofitError and throws a customised Spinnaker*Exception
…with the existing formatting
…r to wrap up the customised Spinnaker*Exception
…itError to more specific Retrofit network error
ad810fa
to
104a510
Compare
import java.nio.charset.Charset | ||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus | ||
import com.netflix.spinnaker.orca.api.pipeline.TaskResult | ||
import com.netflix.spinnaker.orca.clouddriver.InstanceService | ||
import com.netflix.spinnaker.orca.pipeline.model.PipelineExecutionImpl | ||
import com.netflix.spinnaker.orca.pipeline.model.StageExecutionImpl | ||
import retrofit.RetrofitError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surprised spotless doesn't re-order the imports. Can you reconfigure intellij to match what was here before and minimize the diffs please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reordered the import statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would have been good to re-order the other two as well.
As part of this PR , the target is to eliminate the usage of RetrofitError in InstanceService retrofit client under module orca-clouddriver.
Replaced the exception handling logic with the handleError method under SpinnakerRetrofitErrorHandler class.