Skip to content

Commit e7d0b2e

Browse files
committed
Fix Spotbugs
1 parent 976c348 commit e7d0b2e

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/main/java/com/imsweb/seerapi/client/ErrorInterceptor.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
package com.imsweb.seerapi.client;
55

66
import java.io.IOException;
7-
import java.util.Objects;
87

98
import org.jetbrains.annotations.NotNull;
109

1110
import com.fasterxml.jackson.databind.ObjectMapper;
1211

1312
import okhttp3.Interceptor;
1413
import okhttp3.Response;
14+
import okhttp3.ResponseBody;
1515

1616
/**
1717
* Interceptor to catch all non-200 responses and convert them to exceptions.
@@ -24,11 +24,13 @@ public Response intercept(Chain chain) throws IOException {
2424
Response response = chain.proceed(chain.request());
2525

2626
if (response.code() != 200) {
27-
// convert body to error response
2827
ErrorResponse error = null;
29-
if (response.body() != null) {
28+
29+
// convert body to error response
30+
ResponseBody body = response.body();
31+
if (body != null) {
3032
try {
31-
error = new ObjectMapper().readValue(Objects.requireNonNull(response.body()).byteStream(), ErrorResponse.class);
33+
error = new ObjectMapper().readValue(body.byteStream(), ErrorResponse.class);
3234
}
3335
catch (IOException e) {
3436
// sometimes the error message is not right format (like for 404 errors)

0 commit comments

Comments
 (0)