Skip to content

Commit 7d949f7

Browse files
committed
Fix Sonar issues
1 parent 58c0b98 commit 7d949f7

File tree

3 files changed

+28
-22
lines changed

3 files changed

+28
-22
lines changed

spring-integration-core/src/main/java/org/springframework/integration/graph/IntegrationGraphServer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat
8181

8282
@Override
8383
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
84-
this.applicationContext = applicationContext; //NOSONAR (sync)
84+
this.applicationContext = applicationContext; // NOSONAR (sync)
8585
}
8686

8787
protected ApplicationContext getApplicationContext() {
88-
return this.applicationContext;
88+
return this.applicationContext; // NOSONAR (sync)
8989
}
9090

9191
/**

spring-integration-core/src/main/java/org/springframework/integration/graph/IntegrationNode.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ public void addProperties(@Nullable Map<String, Object> props) {
109109

110110
public static class Stats {
111111

112-
private final String deprecated = "stats are deprecated in favor of sendTimers and receiveCounters";
112+
private static final String deprecated = "stats are deprecated in favor of sendTimers and receiveCounters";
113113

114114
protected boolean isAvailable() {
115115
return false;
116116
}
117117

118118
public String getDeprecated() {
119-
return this.deprecated;
119+
return deprecated;
120120
}
121121

122122
}

spring-integration-core/src/main/java/org/springframework/integration/graph/MicrometerNodeEnhancer.java

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@
3535
*/
3636
public class MicrometerNodeEnhancer {
3737

38+
private static final String UNUSED = "unused";
39+
40+
private static final String TAG_TYPE = "type";
41+
42+
private static final String TAG_NAME = "name";
43+
44+
private static final String TAG_RESULT = "result";
45+
3846
private static final TimerStats ZERO_TIMER_STATS = new TimerStats(0L, 0.0, 0.0);
3947

4048
private final MeterRegistry registry;
@@ -81,25 +89,23 @@ private <T extends IntegrationNode> SendTimers retrieveTimers(T node, String typ
8189
Timer successTimer = null;
8290
try {
8391
successTimer = this.registry.get(IntegrationManagement.SEND_TIMER_NAME)
84-
.tag("type", type)
85-
.tag("name", node.getName())
86-
.tag("result", "success")
92+
.tag(TAG_TYPE, type)
93+
.tag(TAG_NAME, node.getName())
94+
.tag(TAG_RESULT, "success")
8795
.timer();
8896
}
89-
catch (@SuppressWarnings("unused")
90-
Exception e) {
97+
catch (@SuppressWarnings(UNUSED) Exception e) { // NOSONAR ignored
9198
// NOSONAR empty
9299
}
93100
Timer failureTimer = null;
94101
try {
95102
failureTimer = this.registry.get(IntegrationManagement.SEND_TIMER_NAME)
96-
.tag("type", type)
97-
.tag("name", node.getName())
98-
.tag("result", "failure")
103+
.tag(TAG_TYPE, type)
104+
.tag(TAG_NAME, node.getName())
105+
.tag(TAG_RESULT, "failure")
99106
.timer();
100107
}
101-
catch (@SuppressWarnings("unused")
102-
Exception e) {
108+
catch (@SuppressWarnings(UNUSED) Exception e) { // NOSONAR ignored
103109
// NOSONAR empty;
104110
}
105111
TimerStats successes = successTimer == null ? ZERO_TIMER_STATS
@@ -120,23 +126,23 @@ private <T extends IntegrationNode> ReceiveCounters retrieveCounters(T node, Str
120126
String name = node.getName();
121127
try {
122128
successes = this.registry.get(IntegrationManagement.RECEIVE_COUNTER_NAME)
123-
.tag("type", type)
124-
.tag("name", name)
125-
.tag("result", "success")
129+
.tag(TAG_TYPE, type)
130+
.tag(TAG_NAME, name)
131+
.tag(TAG_RESULT, "success")
126132
.counter();
127133
}
128-
catch (@SuppressWarnings("unused") Exception e) {
134+
catch (@SuppressWarnings(UNUSED) Exception e) { // NOSONAR ignored
129135
// NOSONAR empty;
130136
}
131137
Counter failures = null;
132138
try {
133139
failures = this.registry.get(IntegrationManagement.RECEIVE_COUNTER_NAME)
134-
.tag("type", type)
135-
.tag("name", name)
136-
.tag("result", "failure")
140+
.tag(TAG_TYPE, type)
141+
.tag(TAG_NAME, name)
142+
.tag(TAG_RESULT, "failure")
137143
.counter();
138144
}
139-
catch (@SuppressWarnings("unused") Exception e) {
145+
catch (@SuppressWarnings(UNUSED) Exception e) { // NOSONAR ignored
140146
// NOSONAR empty;
141147
}
142148
return new ReceiveCounters(

0 commit comments

Comments
 (0)