File tree Expand file tree Collapse file tree
src/main/java/com/imsweb/seerapi/client Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ dependencies {
3939 api ' com.squareup.retrofit2:retrofit:2.9.0'
4040 api ' com.squareup.retrofit2:converter-jackson:2.9.0'
4141
42+ // retrofit will not update these dependencies to fix vulnerabilities
43+ api ' com.squareup.okhttp3:okhttp:4.9.3'
44+
4245 // newer version of dependency to fix vulnerability until converter-jackson is updated
4346 api ' com.fasterxml.jackson.core:jackson-databind:2.13.3'
4447
Original file line number Diff line number Diff line change 55
66import java .io .IOException ;
77
8+ import org .jetbrains .annotations .NotNull ;
9+
810import com .fasterxml .jackson .databind .ObjectMapper ;
911
1012import okhttp3 .Interceptor ;
1113import okhttp3 .Response ;
14+ import okhttp3 .ResponseBody ;
1215
1316/**
1417 * Interceptor to catch all non-200 responses and convert them to exceptions.
1518 */
1619public class ErrorInterceptor implements Interceptor {
1720
21+ @ NotNull
1822 @ Override
1923 public Response intercept (Chain chain ) throws IOException {
2024 Response response = chain .proceed (chain .request ());
2125
2226 if (response .code () != 200 ) {
23- // convert body to error response
2427 ErrorResponse error = null ;
25- if (response .body () != null ) {
28+
29+ // convert body to error response
30+ ResponseBody body = response .body ();
31+ if (body != null ) {
2632 try {
27- error = new ObjectMapper ().readValue (response . body () .byteStream (), ErrorResponse .class );
33+ error = new ObjectMapper ().readValue (body .byteStream (), ErrorResponse .class );
2834 }
2935 catch (IOException e ) {
3036 // sometimes the error message is not right format (like for 404 errors)
You can’t perform that action at this time.
0 commit comments