Skip to content

Commit 4927cc5

Browse files
committed
GH-1419: Sonar Fixes
1 parent 8045f2c commit 4927cc5

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

Diff for: spring-rabbit-junit/src/main/java/org/springframework/amqp/rabbit/junit/BrokerRunningSupport.java

+9-6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.apache.commons.logging.Log;
3939
import org.apache.commons.logging.LogFactory;
4040

41+
import org.springframework.http.HttpStatus;
4142
import org.springframework.util.Base64Utils;
4243
import org.springframework.util.StringUtils;
4344
import org.springframework.web.util.UriUtils;
@@ -379,11 +380,9 @@ private Channel createQueues(Connection connection) throws IOException, URISynta
379380
channel.queueDeclare(queueName, true, false, false, null);
380381
}
381382
}
382-
if (this.management) {
383-
if (!alivenessTest()) {
384-
throw new BrokerNotAliveException("Aliveness test failed for localhost:15672 guest/quest; "
385-
+ "management not available");
386-
}
383+
if (this.management && !alivenessTest()) {
384+
throw new BrokerNotAliveException("Aliveness test failed for localhost:15672 guest/quest; "
385+
+ "management not available");
387386
}
388387
return channel;
389388
}
@@ -417,7 +416,11 @@ protected PasswordAuthentication getPasswordAuthentication() {
417416
Thread.currentThread().interrupt();
418417
return false;
419418
}
420-
return response.body().contentEquals("{\"status\":\"ok\"}");
419+
String body = null;
420+
if (response.statusCode() == HttpStatus.OK.value()) {
421+
response.body();
422+
}
423+
return body != null && body.contentEquals("{\"status\":\"ok\"}");
421424
}
422425

423426
public static boolean fatal() {

Diff for: spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/WebFluxNodeLocator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public Map<String, Object> restCall(WebClient client, String baseUri, String vho
5454
.bodyToMono(new ParameterizedTypeReference<HashMap<String, Object>>() {
5555
})
5656
.block(Duration.ofSeconds(10)); // NOSONAR magic#
57-
return queueInfo;
57+
return queueInfo != null ? queueInfo : null;
5858
}
5959

6060
/**

0 commit comments

Comments
 (0)