Resolve Sonar Reported Bugs
This commit is contained in:
@@ -37,7 +37,7 @@ import org.springframework.util.StopWatch;
|
||||
@ManagedResource
|
||||
public class PayloadAwareTimingInterceptor implements ChannelInterceptor {
|
||||
|
||||
private final ThreadLocal<StopWatchHolder> stopWatchHolder = new ThreadLocal<PayloadAwareTimingInterceptor.StopWatchHolder>();
|
||||
private static final ThreadLocal<StopWatchHolder> stopWatchHolder = new ThreadLocal<PayloadAwareTimingInterceptor.StopWatchHolder>();
|
||||
|
||||
private final Map<Class<?>, Stats> statsMap = new ConcurrentHashMap<Class<?>, PayloadAwareTimingInterceptor.Stats>();
|
||||
|
||||
@@ -59,13 +59,13 @@ public class PayloadAwareTimingInterceptor implements ChannelInterceptor {
|
||||
public Message<?> preSend(Message<?> message, MessageChannel channel) {
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
this.stopWatchHolder.set(new StopWatchHolder(stopWatch, message.getPayload().getClass()));
|
||||
stopWatchHolder.set(new StopWatchHolder(stopWatch, message.getPayload().getClass()));
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postSend(Message<?> message, MessageChannel channel, boolean sent) {
|
||||
StopWatchHolder holder = this.stopWatchHolder.get();
|
||||
StopWatchHolder holder = stopWatchHolder.get();
|
||||
if (holder != null) {
|
||||
holder.getStopWatch().stop();
|
||||
Stats stats = this.statsMap.get(holder.getType());
|
||||
@@ -125,7 +125,7 @@ public class PayloadAwareTimingInterceptor implements ChannelInterceptor {
|
||||
}
|
||||
}
|
||||
|
||||
private class Stats {
|
||||
private static final class Stats {
|
||||
|
||||
private long count;
|
||||
|
||||
@@ -159,6 +159,6 @@ public class PayloadAwareTimingInterceptor implements ChannelInterceptor {
|
||||
return "Stats [count=" + count + ", average=" + average + ", lastTime=" + lastTime + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public final class DerbyStoredProcedures {
|
||||
public static void findCoffee(int coffeeId, String[] coffeeDescription)
|
||||
throws SQLException {
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
PreparedStatement statement = null; // NOSONAR JdbcUtils
|
||||
|
||||
try {
|
||||
connection = DriverManager.getConnection("jdbc:default:connection");
|
||||
@@ -46,7 +46,7 @@ public final class DerbyStoredProcedures {
|
||||
statement = connection.prepareStatement(sql);
|
||||
statement.setLong(1, coffeeId);
|
||||
|
||||
ResultSet resultset = statement.executeQuery();
|
||||
ResultSet resultset = statement.executeQuery(); // NOSONAR JdbcUtils
|
||||
resultset.next();
|
||||
coffeeDescription[0] = resultset.getString("COFFEE_DESCRIPTION");
|
||||
|
||||
@@ -61,7 +61,7 @@ public final class DerbyStoredProcedures {
|
||||
public static void findAllCoffeeBeverages(ResultSet[] coffeeBeverages)
|
||||
throws SQLException {
|
||||
|
||||
Connection connection = null;
|
||||
Connection connection = null; // NOSONAR JdbcUtils
|
||||
PreparedStatement statement = null;
|
||||
|
||||
try {
|
||||
@@ -76,4 +76,5 @@ public final class DerbyStoredProcedures {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user