-
Notifications
You must be signed in to change notification settings - Fork 172
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
feat(retrofit): move url attribute from SpinnakerHttpException to SpinnakerServerException #1110
feat(retrofit): move url attribute from SpinnakerHttpException to SpinnakerServerException #1110
Conversation
to use fluent assertions and other small tweaks
to prepare to move url to SpinnakerServerException
…2ErrorHandleTest testRetrofitSimpleSpinnakerServerException actually generates a SpinnakerNetworkException and so it's effectively the same test as testRetrofitSimpleSpinnakerNetworkException.
…innakerNetworkException
…nnakerServerException so it's available to exception handling code that currently has access to the url via 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.
Overall looks good! One minor design consideration, but overall I like the approach
@@ -59,11 +59,11 @@ public Throwable handleError(RetrofitError e) { | |||
} | |||
return retval; | |||
case NETWORK: | |||
return new SpinnakerNetworkException(e.getMessage(), e.getCause()); | |||
return new SpinnakerNetworkException(e); |
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.
This becomes easy to change too
return new SpinnakerNetworkException(e); | |
return new SpinnakerNetworkException(e.getMessage(), e.getCause(), e.getUrl()); |
} | ||
|
||
public SpinnakerServerException() {} | ||
public SpinnakerServerException(String message, Throwable cause, String url) { |
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 think with this new method signature, we can probably get rid of all the retrofit constructors tbh.
This will at least clean up the other exceptions and only require updating the one constructor in each other exception. This also keeps the SpinnakerServerException
pretty agnostic to retrofit, which may be a better approach for now since we are only interested in the URL at this point. Further, if we do end up with more fields from retrofit in this particular class, we can revisit. However, let's keep it simple and just add the one field :)
case CONVERSION: | ||
return new SpinnakerConversionException(e.getMessage(), e.getCause()); | ||
return new SpinnakerConversionException(e); |
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.
return new SpinnakerConversionException(e); | |
return new SpinnakerConversionException(e.getMessage(), e.getCause(), e.getUrl()); |
default: | ||
return new SpinnakerServerException(e.getMessage(), e.getCause()); | ||
return new SpinnakerServerException(e); |
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.
return new SpinnakerServerException(e); | |
return new SpinnakerServerException(e.getMessage(), e.getCause(), e.getUrl()); |
super(message, cause); | ||
private final String url; | ||
|
||
public SpinnakerServerException(RetrofitError e) { |
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.
Then these go away and allows for only the SpinnakerHttpException
to utilize all the retrofit fields
… Request instead of a url, to pave the way for storing other attributes of requests (e.g. the http request method)
…e new SpinnakerConversionException constructors
public SpinnakerConversionException(RetrofitError e) { | ||
super(e); | ||
setRetryable(false); |
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.
Oof, that sucks we need to add the false everywhere. May be nice to have a implements NonRetryableException
or something like that, but that is separate from this PR
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.
@dbyron-sf Thank you for the improvements! The javadocs are fantastic :) and really helped me understand the use cases.
I had one very minor nit comment, but this change looks really good :)
...t/src/main/java/com/netflix/spinnaker/kork/retrofit/exceptions/SpinnakerServerException.java
Outdated
Show resolved
Hide resolved
...t/src/main/java/com/netflix/spinnaker/kork/retrofit/exceptions/SpinnakerServerException.java
Outdated
Show resolved
Hide resolved
...t/src/main/java/com/netflix/spinnaker/kork/retrofit/exceptions/SpinnakerServerException.java
Outdated
Show resolved
Hide resolved
...t/src/main/java/com/netflix/spinnaker/kork/retrofit/exceptions/SpinnakerServerException.java
Outdated
Show resolved
Hide resolved
...t/src/main/java/com/netflix/spinnaker/kork/retrofit/exceptions/SpinnakerServerException.java
Outdated
Show resolved
Hide resolved
...t/src/main/java/com/netflix/spinnaker/kork/retrofit/exceptions/SpinnakerServerException.java
Show resolved
Hide resolved
…etworkException constructor changes from spinnaker/kork#1110
* chore(dependencies): Autobump korkVersion * fix(manifests/test): keep up with SpinnakerNetworkException constructor changes from spinnaker/kork#1110 --------- Co-authored-by: root <root@2f91e8016c3c> Co-authored-by: David Byron <dbyron@salesforce.com>
* chore(dependencies): Autobump korkVersion * fix(retrofit/test): keep up with SpinnakerServerException, SpinnakerNetworkException constructor changes from spinnaker/kork#1110 --------- Co-authored-by: root <root@2f91e8016c3c> Co-authored-by: David Byron <dbyron@salesforce.com>
…OfProject The jenkinsClient inside JenkinsService comes from JenkinsConfig, wihch, as of spinnaker#1130, uses SpinnakerRetrofitErrorHandler. Therefore, the getBuilds calls inside the try/catch block inside processBuildsOfProject throws a SpinnakerServerException. spinnaker#1130 updated the 'should continue processing other builds from a master even if one or more build fetches fail' test to throw a SpinnakerServerException with a RetrofitError as its cause instead of a RuntimeException with a RetrofitError as its cause. With spinnaker/kork#1110, the SpinnakerServerException no longer has a RetrofitError as its cause. It has the "mock root cause" exception as its cause. But, because spinnaker/kork#1110 adds a url attribute to SpinnakerServerException, the cause is no longer necessary for including a url in the "Error communicating with jenkins" log message, and this commit updates the logic accordingly.
* chore(dependencies): Autobump korkVersion * fix(web): fix exception handling in JenkinsBuildMonitor.processBuildsOfProject The jenkinsClient inside JenkinsService comes from JenkinsConfig, wihch, as of #1130, uses SpinnakerRetrofitErrorHandler. Therefore, the getBuilds calls inside the try/catch block inside processBuildsOfProject throws a SpinnakerServerException. #1130 updated the 'should continue processing other builds from a master even if one or more build fetches fail' test to throw a SpinnakerServerException with a RetrofitError as its cause instead of a RuntimeException with a RetrofitError as its cause. With spinnaker/kork#1110, the SpinnakerServerException no longer has a RetrofitError as its cause. It has the "mock root cause" exception as its cause. But, because spinnaker/kork#1110 adds a url attribute to SpinnakerServerException, the cause is no longer necessary for including a url in the "Error communicating with jenkins" log message, and this commit updates the logic accordingly. * refactor(web/test): clean up exception mocking in JenkinsBuildMonitorSpec remove unused runtimeException and rename retrofitEx since it's no longer a retrofitEx --------- Co-authored-by: root <root@2f91e8016c3c> Co-authored-by: David Byron <dbyron@salesforce.com>
* chore(dependencies): Autobump korkVersion * fix(aws/test): keep up with SpinnakerNetworkException constructor changes from spinnaker/kork#1110 --------- Co-authored-by: root <root@2f91e8016c3c> Co-authored-by: David Byron <dbyron@salesforce.com>
* chore(dependencies): Autobump orcaVersion * fix(core/test): keep up with SpinnakerNetworkException constructor changes from spinnaker/kork#1110 --------- Co-authored-by: root <root@37e47cedb6bb> Co-authored-by: David Byron <dbyron@salesforce.com>
* chore(dependencies): Autobump korkVersion * fix(retrofit/test): keep up with SpinnakerServerException, SpinnakerNetworkException constructor changes from spinnaker/kork#1110 --------- Co-authored-by: root <root@2f91e8016c3c> Co-authored-by: David Byron <dbyron@salesforce.com> feat(retrofit2): orca-clouddriver: InstanceService - Eliminated the usage of RetrofitError in the catch blocks and added SpinnakerRetrofitErrorHandler in the retrofit config
so it's available to exception handling code that currently has access to the url via RetrofitError.