Skip to content

Commit 7164524

Browse files
committed
Address Spotbugs issues in dependency update
1 parent 6034688 commit 7164524

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/main/java/org/kohsuke/github/extras/okhttp3/ObsoleteUrlFactory.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,16 @@ static long contentLength(Headers headers) {
220220
}
221221

222222
static String responseSourceHeader(Response response) {
223-
if (response.networkResponse() == null) {
223+
Response networkResponse = response.networkResponse();
224+
if (networkResponse == null) {
224225
return response.cacheResponse() == null
225226
? "NONE"
226227
: "CACHE " + response.code();
228+
} else {
229+
return response.cacheResponse() == null
230+
? "NETWORK " + response.code()
231+
: "CONDITIONAL_CACHE " + networkResponse.code();
227232
}
228-
return response.cacheResponse() == null
229-
? "NETWORK " + response.code()
230-
: "CONDITIONAL_CACHE " + response.networkResponse().code();
231233
}
232234

233235
static String statusLineToString(Response response) {
@@ -351,6 +353,8 @@ static final class OkHttpURLConnection extends HttpURLConnection implements Call
351353
call.cancel();
352354
}
353355

356+
@SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE",
357+
justification = "hasBody checks for this")
354358
@Override public InputStream getErrorStream() {
355359
try {
356360
Response response = getResponse(true);
@@ -422,6 +426,8 @@ Headers getHeaders() throws IOException {
422426
return toMultimap(requestHeaders.build(), null);
423427
}
424428

429+
@SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE",
430+
justification = "Good request will have body")
425431
@Override public InputStream getInputStream() throws IOException {
426432
if (!doInput) {
427433
throw new ProtocolException("This protocol does not support input");
@@ -450,6 +456,8 @@ Headers getHeaders() throws IOException {
450456
return requestBody.outputStream;
451457
}
452458

459+
@SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE",
460+
justification = "usingProxy() handles this")
453461
@Override public Permission getPermission() {
454462
URL url = getURL();
455463
String hostname = url.getHost();
@@ -714,6 +722,8 @@ public void proceed() {
714722
}
715723
}
716724

725+
@SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE",
726+
justification = "If we get here there is a connection and request.body() is checked")
717727
@Override public Response intercept(Chain chain) throws IOException {
718728
Request request = chain.request();
719729

0 commit comments

Comments
 (0)