Skip to content

Commit c2c534d

Browse files
committed
GH-1419: Sonar Fixes
1 parent 1713452 commit c2c534d

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

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

+8-6
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,9 @@ private Channel createQueues(Connection connection) throws IOException, URISynta
387387
channel.queueDeclare(queueName, true, false, false, null);
388388
}
389389
}
390-
if (this.management) {
391-
if (!alivenessTest()) {
392-
throw new BrokerNotAliveException("Aliveness test failed for localhost:15672 guest/quest; "
393-
+ "management not available");
394-
}
390+
if (this.management && !alivenessTest()) {
391+
throw new BrokerNotAliveException("Aliveness test failed for localhost:15672 guest/quest; "
392+
+ "management not available");
395393
}
396394
return channel;
397395
}
@@ -416,7 +414,11 @@ protected HttpContext createHttpContext(HttpMethod httpMethod, URI uri) {
416414
});
417415
template.getInterceptors().add(new BasicAuthenticationInterceptor(this.adminUser, this.adminPassword));
418416
ResponseEntity<String> response = template.exchange(uri, HttpMethod.GET, null, String.class);
419-
return response.getStatusCode().equals(HttpStatus.OK)
417+
String body = null;
418+
if (response.getStatusCode().equals(HttpStatus.OK)) {
419+
body = response.getBody();
420+
}
421+
return body != null
420422
? response.getBody().equals("{\"status\":\"ok\"}")
421423
: false;
422424
}

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)