You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2020/03/09 03:37:00 UTC
[skywalking] branch master updated: Remove & Simplfy redundancy
code. (#4467)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new f0385ff Remove & Simplfy redundancy code. (#4467)
f0385ff is described below
commit f0385ff7b0bf69442d168d5a2afad681e8a9ec2d
Author: Weiyi Liu <li...@cmss.chinamobile.com>
AuthorDate: Mon Mar 9 11:36:48 2020 +0800
Remove & Simplfy redundancy code. (#4467)
Co-authored-by: 吴晟 Wu Sheng <wu...@foxmail.com>
---
.../plugin/jdbc/h2/dao/H2AggregationQueryDAO.java | 20 +++++++-------------
.../plugin/jdbc/mysql/MySQLAggregationQueryDAO.java | 19 +++++++------------
2 files changed, 14 insertions(+), 25 deletions(-)
diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2AggregationQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2AggregationQueryDAO.java
index b75682e..dea2b0b 100644
--- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2AggregationQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2AggregationQueryDAO.java
@@ -101,19 +101,13 @@ public class H2AggregationQueryDAO implements IAggregationQueryDAO {
sql.append(" group by ").append(Metrics.ENTITY_ID);
sql.append(") order by value ").append(order.equals(Order.ASC) ? "asc" : "desc").append(" limit ").append(topN);
List<TopNEntity> topNEntities = new ArrayList<>();
- try (Connection connection = h2Client.getConnection()) {
- try (ResultSet resultSet = h2Client.executeQuery(connection, sql.toString(), conditions.toArray(new Object[0]))) {
-
- try {
- while (resultSet.next()) {
- TopNEntity topNEntity = new TopNEntity();
- topNEntity.setId(resultSet.getString(Metrics.ENTITY_ID));
- topNEntity.setValue(resultSet.getLong("value"));
- topNEntities.add(topNEntity);
- }
- } catch (SQLException e) {
- throw new IOException(e);
- }
+ try (Connection connection = h2Client.getConnection();
+ ResultSet resultSet = h2Client.executeQuery(connection, sql.toString(), conditions.toArray(new Object[0]))) {
+ while (resultSet.next()) {
+ TopNEntity topNEntity = new TopNEntity();
+ topNEntity.setId(resultSet.getString(Metrics.ENTITY_ID));
+ topNEntity.setValue(resultSet.getLong("value"));
+ topNEntities.add(topNEntity);
}
} catch (SQLException e) {
throw new IOException(e);
diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLAggregationQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLAggregationQueryDAO.java
index a636ac3..b175ea7 100644
--- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLAggregationQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLAggregationQueryDAO.java
@@ -60,18 +60,13 @@ public class MySQLAggregationQueryDAO extends H2AggregationQueryDAO {
sql.append(" order by value ").append(order.equals(Order.ASC) ? "asc" : "desc").append(" limit ").append(topN);
List<TopNEntity> topNEntities = new ArrayList<>();
- try (Connection connection = getH2Client().getConnection()) {
- try (ResultSet resultSet = getH2Client().executeQuery(connection, sql.toString(), conditions.toArray(new Object[0]))) {
- try {
- while (resultSet.next()) {
- TopNEntity topNEntity = new TopNEntity();
- topNEntity.setId(resultSet.getString(Metrics.ENTITY_ID));
- topNEntity.setValue(resultSet.getLong("value"));
- topNEntities.add(topNEntity);
- }
- } catch (SQLException e) {
- throw new IOException(e);
- }
+ try (Connection connection = getH2Client().getConnection();
+ ResultSet resultSet = getH2Client().executeQuery(connection, sql.toString(), conditions.toArray(new Object[0]))) {
+ while (resultSet.next()) {
+ TopNEntity topNEntity = new TopNEntity();
+ topNEntity.setId(resultSet.getString(Metrics.ENTITY_ID));
+ topNEntity.setValue(resultSet.getLong("value"));
+ topNEntities.add(topNEntity);
}
} catch (SQLException e) {
throw new IOException(e);