From b914af3989514648e57884767372da872097ec92 Mon Sep 17 00:00:00 2001 From: KomachiSion <263976490@qq.com> Date: Fri, 12 Jun 2020 20:16:49 +0800 Subject: [PATCH 1/2] Ignore kind/notice label for issue robot --- .github/stale.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/stale.yml b/.github/stale.yml index 45dde9473..0f219bc56 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -16,6 +16,7 @@ exemptLabels: - kind/user experience - Soc2019 - SoC2020 + - kind/notice # Label to use when marking an issue as stale staleLabel: expired # Comment to post when marking an issue as stale. Set to `false` to disable From 8c0f52f98714b23ef03c297388d016468aea4358 Mon Sep 17 00:00:00 2001 From: Brian Huang Date: Fri, 12 Jun 2020 22:00:08 +0800 Subject: [PATCH 2/2] replace "+=" to StringBuilder append method --- .../EmbeddedStoragePersistServiceImpl.java | 82 +++++++++---------- .../ExternalStoragePersistServiceImpl.java | 80 +++++++++--------- 2 files changed, 81 insertions(+), 81 deletions(-) diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/EmbeddedStoragePersistServiceImpl.java b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/EmbeddedStoragePersistServiceImpl.java index 35587e8e0..a8577e9ba 100755 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/EmbeddedStoragePersistServiceImpl.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/EmbeddedStoragePersistServiceImpl.java @@ -991,7 +991,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService { } PaginationHelper helper = createPaginationHelper(); return helper - .fetchPage(sqlCount + where, sql + where, paramList.toArray(), pageNo, + .fetchPage(sqlCount + where.toString(), sql + where.toString(), paramList.toArray(), pageNo, pageSize, CONFIG_INFO_ROW_MAPPER); } @@ -1597,7 +1597,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService { final ConfigKey[] configKeys, final boolean blacklist) { String sqlCountRows = "select count(*) from config_info where "; String sqlFetchRows = "select ID,data_id,group_id,tenant_id,app_name,content from config_info where "; - String where = " 1=1 "; + StringBuilder where = new StringBuilder(" 1=1 "); // White list, please synchronize the condition is empty, there is no qualified configuration if (configKeys.length == 0 && !blacklist) { Page page = new Page(); @@ -1619,74 +1619,74 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService { if (blacklist) { if (isFirst) { isFirst = false; - where += " and "; + where.append(" and "); } else { - where += " and "; + where.append(" and "); } - where += "("; + where.append("("); boolean isFirstSub = true; if (!StringUtils.isBlank(dataId)) { - where += " data_id not like ? "; + where.append(" data_id not like ? "); params.add(generateLikeArgument(dataId)); isFirstSub = false; } if (!StringUtils.isBlank(group)) { if (!isFirstSub) { - where += " or "; + where.append(" or "); } - where += " group_id not like ? "; + where.append(" group_id not like ? "); params.add(generateLikeArgument(group)); isFirstSub = false; } if (!StringUtils.isBlank(appName)) { if (!isFirstSub) { - where += " or "; + where.append(" or "); } - where += " app_name != ? "; + where.append(" app_name != ? "); params.add(appName); isFirstSub = false; } - where += ") "; + where.append(") "); } else { if (isFirst) { isFirst = false; - where += " and "; + where.append(" and "); } else { - where += " or "; + where.append(" or "); } - where += "("; + where.append("("); boolean isFirstSub = true; if (!StringUtils.isBlank(dataId)) { - where += " data_id like ? "; + where.append(" data_id like ? "); params.add(generateLikeArgument(dataId)); isFirstSub = false; } if (!StringUtils.isBlank(group)) { if (!isFirstSub) { - where += " and "; + where.append(" and "); } - where += " group_id like ? "; + where.append(" group_id like ? "); params.add(generateLikeArgument(group)); isFirstSub = false; } if (!StringUtils.isBlank(appName)) { if (!isFirstSub) { - where += " and "; + where.append(" and "); } - where += " app_name = ? "; + where.append(" app_name = ? "); params.add(appName); isFirstSub = false; } - where += ") "; + where.append(") "); } } PaginationHelper helper = createPaginationHelper(); return helper - .fetchPage(sqlCountRows + where, sqlFetchRows + where, params.toArray(), + .fetchPage(sqlCountRows + where.toString(), sqlFetchRows + where.toString(), params.toArray(), pageNo, pageSize, CONFIG_INFO_ROW_MAPPER); } @@ -1769,7 +1769,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService { String sqlCountRows = "select count(*) from config_info_aggr where "; String sqlFetchRows = "select data_id,group_id,tenant_id,datum_id,app_name,content from config_info_aggr where "; - String where = " 1=1 "; + StringBuilder where = new StringBuilder(" 1=1 "); // White list, please synchronize the condition is empty, there is no qualified configuration if (configKeys.length == 0 && blacklist == false) { Page page = new Page(); @@ -1790,74 +1790,74 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService { if (blacklist) { if (isFirst) { isFirst = false; - where += " and "; + where.append(" and "); } else { - where += " and "; + where.append(" and "); } - where += "("; + where.append("("); boolean isFirstSub = true; if (!StringUtils.isBlank(dataId)) { - where += " data_id not like ? "; + where.append(" data_id not like ? "); params.add(generateLikeArgument(dataId)); isFirstSub = false; } if (!StringUtils.isBlank(group)) { if (!isFirstSub) { - where += " or "; + where.append(" or "); } - where += " group_id not like ? "; + where.append(" group_id not like ? "); params.add(generateLikeArgument(group)); isFirstSub = false; } if (!StringUtils.isBlank(appName)) { if (!isFirstSub) { - where += " or "; + where.append(" or "); } - where += " app_name != ? "; + where.append(" app_name != ? "); params.add(appName); isFirstSub = false; } - where += ") "; + where.append(") "); } else { if (isFirst) { isFirst = false; - where += " and "; + where.append(" and "); } else { - where += " or "; + where.append(" or "); } - where += "("; + where.append("("); boolean isFirstSub = true; if (!StringUtils.isBlank(dataId)) { - where += " data_id like ? "; + where.append(" data_id like ? "); params.add(generateLikeArgument(dataId)); isFirstSub = false; } if (!StringUtils.isBlank(group)) { if (!isFirstSub) { - where += " and "; + where.append(" and "); } - where += " group_id like ? "; + where.append(" group_id like ? "); params.add(generateLikeArgument(group)); isFirstSub = false; } if (!StringUtils.isBlank(appName)) { if (!isFirstSub) { - where += " and "; + where.append(" and "); } - where += " app_name = ? "; + where.append(" app_name = ? "); params.add(appName); isFirstSub = false; } - where += ") "; + where.append(") "); } } PaginationHelper helper = createPaginationHelper(); return helper - .fetchPage(sqlCountRows + where, sqlFetchRows + where, params.toArray(), + .fetchPage(sqlCountRows + where.toString(), sqlFetchRows + where.toString(), params.toArray(), pageNo, pageSize, CONFIG_INFO_AGGR_ROW_MAPPER); } diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/ExternalStoragePersistServiceImpl.java b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/ExternalStoragePersistServiceImpl.java index 585c316f9..9928bf773 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/ExternalStoragePersistServiceImpl.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/ExternalStoragePersistServiceImpl.java @@ -1926,7 +1926,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService { final ConfigKey[] configKeys, final boolean blacklist) { String sqlCountRows = "select count(*) from config_info where "; String sqlFetchRows = "select ID,data_id,group_id,tenant_id,app_name,content from config_info where "; - String where = " 1=1 "; + StringBuilder where = new StringBuilder(" 1=1 "); // 白名单,请同步条件为空,则没有符合条件的配置 if (configKeys.length == 0 && blacklist == false) { Page page = new Page(); @@ -1949,74 +1949,74 @@ public class ExternalStoragePersistServiceImpl implements PersistService { if (blacklist) { if (isFirst) { isFirst = false; - where += " and "; + where.append(" and "); } else { - where += " and "; + where.append(" and "); } - where += "("; + where.append("("); boolean isFirstSub = true; if (!StringUtils.isBlank(dataId)) { - where += " data_id not like ? "; + where.append(" data_id not like ? "); params.add(generateLikeArgument(dataId)); isFirstSub = false; } if (!StringUtils.isBlank(group)) { if (!isFirstSub) { - where += " or "; + where.append(" or "); } - where += " group_id not like ? "; + where.append(" group_id not like ? "); params.add(generateLikeArgument(group)); isFirstSub = false; } if (!StringUtils.isBlank(appName)) { if (!isFirstSub) { - where += " or "; + where.append(" or "); } - where += " app_name != ? "; + where.append(" app_name != ? "); params.add(appName); isFirstSub = false; } - where += ") "; + where.append(") "); } else { if (isFirst) { isFirst = false; - where += " and "; + where.append(" and "); } else { - where += " or "; + where.append(" or "); } - where += "("; + where.append("("); boolean isFirstSub = true; if (!StringUtils.isBlank(dataId)) { - where += " data_id like ? "; + where.append(" data_id like ? "); params.add(generateLikeArgument(dataId)); isFirstSub = false; } if (!StringUtils.isBlank(group)) { if (!isFirstSub) { - where += " and "; + where.append(" and "); } - where += " group_id like ? "; + where.append(" group_id like ? "); params.add(generateLikeArgument(group)); isFirstSub = false; } if (!StringUtils.isBlank(appName)) { if (!isFirstSub) { - where += " and "; + where.append(" and "); } - where += " app_name = ? "; + where.append(" app_name = ? "); params.add(appName); isFirstSub = false; } - where += ") "; + where.append(") "); } } try { - return helper.fetchPage(sqlCountRows + where, sqlFetchRows + where, + return helper.fetchPage(sqlCountRows + where.toString(), sqlFetchRows + where.toString(), params.toArray(), pageNo, pageSize, CONFIG_INFO_ROW_MAPPER); } catch (CannotGetJdbcConnectionException e) { @@ -2168,7 +2168,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService { String sqlCountRows = "select count(*) from config_info_aggr where "; String sqlFetchRows = "select data_id,group_id,tenant_id,datum_id,app_name,content from config_info_aggr where "; - String where = " 1=1 "; + StringBuilder where = new StringBuilder(" 1=1 "); // 白名单,请同步条件为空,则没有符合条件的配置 if (configKeys.length == 0 && blacklist == false) { Page page = new Page(); @@ -2190,75 +2190,75 @@ public class ExternalStoragePersistServiceImpl implements PersistService { if (blacklist) { if (isFirst) { isFirst = false; - where += " and "; + where.append(" and "); } else { - where += " and "; + where.append(" and "); } - where += "("; + where.append("("); boolean isFirstSub = true; if (!StringUtils.isBlank(dataId)) { - where += " data_id not like ? "; + where.append(" data_id not like ? "); params.add(generateLikeArgument(dataId)); isFirstSub = false; } if (!StringUtils.isBlank(group)) { if (!isFirstSub) { - where += " or "; + where.append(" or "); } - where += " group_id not like ? "; + where.append(" group_id not like ? "); params.add(generateLikeArgument(group)); isFirstSub = false; } if (!StringUtils.isBlank(appName)) { if (!isFirstSub) { - where += " or "; + where.append(" or "); } - where += " app_name != ? "; + where.append(" app_name != ? "); params.add(appName); isFirstSub = false; } - where += ") "; + where.append(") "); } else { if (isFirst) { isFirst = false; - where += " and "; + where.append(" and "); } else { - where += " or "; + where.append(" or "); } - where += "("; + where.append("("); boolean isFirstSub = true; if (!StringUtils.isBlank(dataId)) { - where += " data_id like ? "; + where.append(" data_id like ? "); params.add(generateLikeArgument(dataId)); isFirstSub = false; } if (!StringUtils.isBlank(group)) { if (!isFirstSub) { - where += " and "; + where.append(" and "); } - where += " group_id like ? "; + where.append(" group_id like ? "); params.add(generateLikeArgument(group)); isFirstSub = false; } if (!StringUtils.isBlank(appName)) { if (!isFirstSub) { - where += " and "; + where.append(" and "); } - where += " app_name = ? "; + where.append(" app_name = ? "); params.add(appName); isFirstSub = false; } - where += ") "; + where.append(") "); } } try { Page result = helper - .fetchPage(sqlCountRows + where, sqlFetchRows + where, + .fetchPage(sqlCountRows + where.toString(), sqlFetchRows + where.toString(), params.toArray(), pageNo, pageSize, CONFIG_INFO_AGGR_ROW_MAPPER); return result;