[Optimize]优化Sonar代码扫描结果

This commit is contained in:
zengqiao
2022-12-14 14:07:30 +08:00
parent 4543a339b7
commit cd2c388e68
3 changed files with 5 additions and 5 deletions

View File

@@ -392,13 +392,13 @@ public class ConnectorMetricServiceImpl extends BaseConnectorMetricService imple
}
private List<Tuple<Long, String>> listTopNConnectorList(Long clusterPhyId, Integer topN) {
List<ConnectorPO> connectorPOS = connectorService.listByKafkaClusterIdFromDB(clusterPhyId);
List<ConnectorPO> poList = connectorService.listByKafkaClusterIdFromDB(clusterPhyId);
if (CollectionUtils.isEmpty(connectorPOS)) {
if (CollectionUtils.isEmpty(poList)) {
return new ArrayList<>();
}
return connectorPOS.subList(0, Math.min(topN, connectorPOS.size()))
return poList.subList(0, Math.min(topN, poList.size()))
.stream()
.map( c -> new Tuple<>(c.getId(), c.getConnectorName()) )
.collect(Collectors.toList());

View File

@@ -185,7 +185,7 @@ public class TopicMetricServiceImpl extends BaseMetricService implements TopicMe
Table<String/*metric*/, String/*topics*/, List<MetricPointVO>> retTable;
if(CollectionUtils.isEmpty(topics)) {
//如果 es 中获取不到topN的topic就使用从数据库中获取的topics
List<String> defaultTopics = listTopNTopics(clusterId, topN);
List<String> defaultTopics = this.listTopNTopics(clusterId, topN);
retTable = topicMetricESDAO.listTopicMetricsByTopN(clusterId, defaultTopics, metrics, aggType, topN, startTime, endTime );
}else {
retTable = topicMetricESDAO.listTopicMetricsByTopics(clusterId, metrics, aggType, topics, startTime, endTime);