Skip to content

Commit

Permalink
Fix Sonar issues
Browse files Browse the repository at this point in the history
- Add private constructor for the utility class HealthStatus
- Check for nullability of the connectionStatus boxed boolean

#1964
  • Loading branch information
smcvb committed Mar 9, 2022
1 parent 1c558ec commit f3a927c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ public abstract class HealthStatus {
* A {@link Status} suggesting the connection is still working but not at full capacity.
*/
public static final Status WARN = new Status("WARN");

private HealthStatus() {
// Utility class
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ protected void doHealthCheck(Health.Builder builder) {
Map<String, Boolean> connections = connectionManager.connections();

connections.forEach((context, connectionStatus) -> {
if (!connectionStatus) {
String contextStatusCode;
if (Boolean.FALSE.equals(connectionStatus)) {
contextStatusCode = Status.DOWN.getCode();
builder.status(HealthStatus.WARN);
} else {
contextStatusCode = Status.UP.getCode();
anyConnectionUp.compareAndSet(false, true);
}
builder.withDetail(String.format(CONNECTION, context),
connectionStatus ? Status.UP.getCode() : Status.DOWN.getCode());
builder.withDetail(String.format(CONNECTION, context), contextStatusCode);
});

if (!connections.isEmpty() && !anyConnectionUp.get()) {
Expand Down

0 comments on commit f3a927c

Please sign in to comment.