From 84235e8c4de6fbac8ba4cccaa5eaba3fa4b24ea3 Mon Sep 17 00:00:00 2001 From: Nigel Armstrong Date: Mon, 15 Mar 2021 12:09:15 -0700 Subject: [PATCH] Fix FindBugs issue FindBugs doesn't recognize `Objects.requireNonNull` as checking null --- .../influxdb/generators/SonarQubePointGenerator.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/jenkinsci/plugins/influxdb/generators/SonarQubePointGenerator.java b/src/main/java/jenkinsci/plugins/influxdb/generators/SonarQubePointGenerator.java index e3d972cf..ee708ba3 100644 --- a/src/main/java/jenkinsci/plugins/influxdb/generators/SonarQubePointGenerator.java +++ b/src/main/java/jenkinsci/plugins/influxdb/generators/SonarQubePointGenerator.java @@ -16,6 +16,7 @@ import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; +import okhttp3.ResponseBody; import org.apache.commons.lang3.StringUtils; import hudson.model.Run; @@ -243,8 +244,12 @@ protected String getResult(String url) throws IOException { if (response.code() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.code() + " from URL : " + url); } + ResponseBody body = response.body(); + if (body == null) { + throw new NullPointerException("Failed : null body from URL : " + url); + } - return Objects.requireNonNull(response.body()).string(); + return body.string(); } }