Fix Sonar issues

This commit is contained in:
Gary Russell
2019-09-21 09:40:25 -04:00
parent 58c0b9885b
commit 7d949f7f8a
3 changed files with 28 additions and 22 deletions

View File

@@ -81,11 +81,11 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext; //NOSONAR (sync)
this.applicationContext = applicationContext; // NOSONAR (sync)
}
protected ApplicationContext getApplicationContext() {
return this.applicationContext;
return this.applicationContext; // NOSONAR (sync)
}
/**

View File

@@ -109,14 +109,14 @@ public abstract class IntegrationNode {
public static class Stats {
private final String deprecated = "stats are deprecated in favor of sendTimers and receiveCounters";
private static final String deprecated = "stats are deprecated in favor of sendTimers and receiveCounters";
protected boolean isAvailable() {
return false;
}
public String getDeprecated() {
return this.deprecated;
return deprecated;
}
}

View File

@@ -35,6 +35,14 @@ import io.micrometer.core.instrument.Timer;
*/
public class MicrometerNodeEnhancer {
private static final String UNUSED = "unused";
private static final String TAG_TYPE = "type";
private static final String TAG_NAME = "name";
private static final String TAG_RESULT = "result";
private static final TimerStats ZERO_TIMER_STATS = new TimerStats(0L, 0.0, 0.0);
private final MeterRegistry registry;
@@ -81,25 +89,23 @@ public class MicrometerNodeEnhancer {
Timer successTimer = null;
try {
successTimer = this.registry.get(IntegrationManagement.SEND_TIMER_NAME)
.tag("type", type)
.tag("name", node.getName())
.tag("result", "success")
.tag(TAG_TYPE, type)
.tag(TAG_NAME, node.getName())
.tag(TAG_RESULT, "success")
.timer();
}
catch (@SuppressWarnings("unused")
Exception e) {
catch (@SuppressWarnings(UNUSED) Exception e) { // NOSONAR ignored
// NOSONAR empty
}
Timer failureTimer = null;
try {
failureTimer = this.registry.get(IntegrationManagement.SEND_TIMER_NAME)
.tag("type", type)
.tag("name", node.getName())
.tag("result", "failure")
.tag(TAG_TYPE, type)
.tag(TAG_NAME, node.getName())
.tag(TAG_RESULT, "failure")
.timer();
}
catch (@SuppressWarnings("unused")
Exception e) {
catch (@SuppressWarnings(UNUSED) Exception e) { // NOSONAR ignored
// NOSONAR empty;
}
TimerStats successes = successTimer == null ? ZERO_TIMER_STATS
@@ -120,23 +126,23 @@ public class MicrometerNodeEnhancer {
String name = node.getName();
try {
successes = this.registry.get(IntegrationManagement.RECEIVE_COUNTER_NAME)
.tag("type", type)
.tag("name", name)
.tag("result", "success")
.tag(TAG_TYPE, type)
.tag(TAG_NAME, name)
.tag(TAG_RESULT, "success")
.counter();
}
catch (@SuppressWarnings("unused") Exception e) {
catch (@SuppressWarnings(UNUSED) Exception e) { // NOSONAR ignored
// NOSONAR empty;
}
Counter failures = null;
try {
failures = this.registry.get(IntegrationManagement.RECEIVE_COUNTER_NAME)
.tag("type", type)
.tag("name", name)
.tag("result", "failure")
.tag(TAG_TYPE, type)
.tag(TAG_NAME, name)
.tag(TAG_RESULT, "failure")
.counter();
}
catch (@SuppressWarnings("unused") Exception e) {
catch (@SuppressWarnings(UNUSED) Exception e) { // NOSONAR ignored
// NOSONAR empty;
}
return new ReceiveCounters(