[ISSUE#11035](PR-2/4) add two string methods & avoid null pointer ... (#11065)
* [#11035] (PR-2/4) add two String methods... * [ISSUE#10908] edit test case, add blank line * [ISSUE#11035] restore a method
This commit is contained in:
parent
8c9934bf06
commit
7b2f7aa92a
@ -129,6 +129,29 @@ public class StringUtils {
|
||||
return isEmpty(str) ? defaultStr : str;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns either the passed in CharSequence, or if the CharSequence is
|
||||
* empty or {@code null} or whitespace only, the value of {@code defaultStr}.</p>
|
||||
*
|
||||
* @param str the CharSequence to check, may be null, may be whitespace only
|
||||
* @param defaultStr the default CharSequence to return if the input is empty ("") or {@code null}, may be null
|
||||
* @return the passed in CharSequence, or the default
|
||||
*/
|
||||
public static String defaultIfBlank(String str, String defaultStr) {
|
||||
return isBlank(str) ? defaultStr : str;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns either the passed in CharSequence, or if the CharSequence is
|
||||
* empty or {@code null} or whitespace only, the value of {@code EmptyString}.</p>
|
||||
*
|
||||
* @param str the CharSequence to check, may be null, may be whitespace only
|
||||
* @return the passed in CharSequence, or the empty string
|
||||
*/
|
||||
public static String defaultEmptyIfBlank(String str) {
|
||||
return defaultIfBlank(str, EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Compares two CharSequences, returning {@code true} if they represent
|
||||
* equal sequences of characters.</p>
|
||||
@ -542,7 +565,7 @@ public class StringUtils {
|
||||
* {@code String} is not {@code null}, its length is greater than 0, and it contains at least one non-whitespace
|
||||
* character.
|
||||
*
|
||||
* @param str the {@code String} to check (may be {@code null})
|
||||
* @param str the {@code String} to check (maybe {@code null})
|
||||
* @return {@code true} if the {@code String} is not {@code null}, its length is greater than 0, and it does not
|
||||
* contain whitespace only
|
||||
* @see Character#isWhitespace
|
||||
@ -698,7 +721,7 @@ public class StringUtils {
|
||||
* <p>Note: this method returns {@code true} for a {@code String} that
|
||||
* purely consists of whitespace.
|
||||
*
|
||||
* @param str the {@code String} to check (may be {@code null})
|
||||
* @param str the {@code String} to check (maybe {@code null})
|
||||
* @return {@code true} if the {@code String} is not {@code null} and has length
|
||||
* @see #hasText(String)
|
||||
*/
|
||||
@ -710,7 +733,7 @@ public class StringUtils {
|
||||
* Take a {@code String} that is a delimited list and convert it into a {@code String} array.
|
||||
*
|
||||
* <p>A single {@code delimiter} may consist of more than one character,
|
||||
* but it will still be considered as a single delimiter string, rather than as bunch of potential delimiter
|
||||
* but it will still be considered as a single delimiter string, rather than as a bunch of potential delimiter
|
||||
* characters, in contrast to {@link #tokenizeToStringArray}.
|
||||
*
|
||||
* @param str the input {@code String} (potentially {@code null} or empty)
|
||||
@ -727,7 +750,7 @@ public class StringUtils {
|
||||
* Take a {@code String} that is a delimited list and convert it into a {@code String} array.
|
||||
*
|
||||
* <p>A single {@code delimiter} may consist of more than one character,
|
||||
* but it will still be considered as a single delimiter string, rather than as bunch of potential delimiter
|
||||
* but it will still be considered as a single delimiter string, rather than as a bunch of potential delimiter
|
||||
* characters, in contrast to {@link #tokenizeToStringArray}.
|
||||
*
|
||||
* @param str the input {@code String} (potentially {@code null} or empty)
|
||||
@ -853,9 +876,9 @@ public class StringUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the filename from the given Java resource path, e.g. {@code "mypath/myfile.txt" → "myfile.txt"}.
|
||||
* Extract the filename from the given Java resource path, e.g. {@code "myPath/myFile.txt" → "myFile.txt"}.
|
||||
*
|
||||
* @param path the file path (may be {@code null})
|
||||
* @param path the file path (maybe {@code null})
|
||||
* @return the extracted filename, or {@code null} if none
|
||||
*/
|
||||
|
||||
|
@ -34,8 +34,6 @@ import com.alibaba.nacos.config.server.utils.PropertyUtil;
|
||||
import com.alibaba.nacos.persistence.configuration.DatasourceConfiguration;
|
||||
import com.alibaba.nacos.sys.utils.ApplicationUtils;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -56,15 +54,13 @@ import static com.alibaba.nacos.config.server.utils.LogUtil.FATAL_LOG;
|
||||
*/
|
||||
public class ConfigCacheService {
|
||||
|
||||
static final Logger LOGGER = LoggerFactory.getLogger(ConfigCacheService.class);
|
||||
|
||||
private static final String NO_SPACE_CN = "设备上没有空间";
|
||||
|
||||
private static final String NO_SPACE_EN = "No space left on device";
|
||||
|
||||
private static final String DISK_QUATA_CN = "超出磁盘限额";
|
||||
private static final String DISK_QUOTA_CN = "超出磁盘限额";
|
||||
|
||||
private static final String DISK_QUATA_EN = "Disk quota exceeded";
|
||||
private static final String DISK_QUOTA_EN = "Disk quota exceeded";
|
||||
|
||||
/**
|
||||
* groupKey -> cacheItem.
|
||||
@ -165,8 +161,8 @@ public class ConfigCacheService {
|
||||
DUMP_LOG.error("[dump-exception] save disk error. " + groupKey + ", " + ioe);
|
||||
if (ioe.getMessage() != null) {
|
||||
String errMsg = ioe.getMessage();
|
||||
if (NO_SPACE_CN.equals(errMsg) || NO_SPACE_EN.equals(errMsg) || errMsg.contains(DISK_QUATA_CN)
|
||||
|| errMsg.contains(DISK_QUATA_EN)) {
|
||||
if (NO_SPACE_CN.equals(errMsg) || NO_SPACE_EN.equals(errMsg) || errMsg.contains(DISK_QUOTA_CN)
|
||||
|| errMsg.contains(DISK_QUOTA_EN)) {
|
||||
// Protect from disk full.
|
||||
FATAL_LOG.error("Local Disk Full,Exit", ioe);
|
||||
System.exit(0);
|
||||
@ -242,7 +238,7 @@ public class ConfigCacheService {
|
||||
if (!PropertyUtil.isDirectRead()) {
|
||||
DUMP_LOG.info(
|
||||
"[dump-beta] md5 changed, update md5 in local disk cache. groupKey={}, newMd5={}, oldMd5={}",
|
||||
new Object[] {groupKey, md5, localContentBetaMd5});
|
||||
groupKey, md5, localContentBetaMd5);
|
||||
|
||||
ConfigDiskServiceFactory.getInstance().saveBetaToDisk(dataId, group, tenant, content);
|
||||
} else {
|
||||
@ -254,23 +250,23 @@ public class ConfigCacheService {
|
||||
boolean ipListChanged = !betaIpList.equals(ConfigCacheService.getBetaIps(groupKey));
|
||||
if (md5Changed) {
|
||||
DUMP_LOG.info(
|
||||
"[dump-beta] md5 changed, update md5 & iplist & timestamp in jvm cache. groupKey={}, newMd5={}, oldMd5={},lastModifiedTs={}",
|
||||
new Object[] {groupKey, md5, localContentBetaMd5, lastModifiedTs});
|
||||
"[dump-beta] md5 changed, update md5 & ip list & timestamp in jvm cache. groupKey={}, newMd5={}, oldMd5={},lastModifiedTs={}",
|
||||
groupKey, md5, localContentBetaMd5, lastModifiedTs);
|
||||
updateBetaMd5(groupKey, md5, betaIpList, lastModifiedTs, encryptedDataKey);
|
||||
} else if (ipListChanged) {
|
||||
DUMP_LOG.warn("[dump-beta] ip list changed, update ip list & timestamp in jvm cache. groupKey={},"
|
||||
+ " newIpList={}, oldIpList={},lastModifiedTs={}",
|
||||
new Object[] {groupKey, betaIpList, ConfigCacheService.getBetaIps(groupKey), lastModifiedTs});
|
||||
+ " newIpList={}, oldIpList={},lastModifiedTs={}", groupKey, betaIpList,
|
||||
ConfigCacheService.getBetaIps(groupKey), lastModifiedTs);
|
||||
updateBetaIpList(groupKey, betaIpList, lastModifiedTs);
|
||||
} else if (timestampUpdated) {
|
||||
DUMP_LOG.warn(
|
||||
"[dump-beta] timestamp changed, update timestamp in jvm cache. groupKey={}, newLastModifiedTs={}, oldLastModifiedTs={}",
|
||||
new Object[] {groupKey, lastModifiedTs, ConfigCacheService.getBetaLastModifiedTs(groupKey)});
|
||||
groupKey, lastModifiedTs, ConfigCacheService.getBetaLastModifiedTs(groupKey));
|
||||
updateBetaTimeStamp(groupKey, lastModifiedTs);
|
||||
} else {
|
||||
DUMP_LOG.warn(
|
||||
"[dump-beta-ignore] ignore to save jvm cache, md5 & ip list & timestamp no changed. groupKey={}",
|
||||
new Object[] {groupKey});
|
||||
groupKey);
|
||||
}
|
||||
return true;
|
||||
} catch (IOException ioe) {
|
||||
@ -334,13 +330,13 @@ public class ConfigCacheService {
|
||||
if (md5Changed) {
|
||||
DUMP_LOG.warn(
|
||||
"[dump-tag] md5 changed, update local jvm cache, groupKey={},tag={}, newMd5={},oldMd5={},lastModifiedTs={}",
|
||||
new Object[] {groupKey, tag, md5, localContentTagMd5, lastModifiedTs});
|
||||
groupKey, tag, md5, localContentTagMd5, lastModifiedTs);
|
||||
updateTagMd5(groupKey, tag, md5, lastModifiedTs, encryptedDataKey4Tag);
|
||||
} else if (timestampChanged) {
|
||||
DUMP_LOG.warn(
|
||||
"[dump-tag] timestamp changed, update last modified in local jvm cache, groupKey={},tag={},"
|
||||
+ "tagLastModifiedTs={},oldTagLastModifiedTs={}",
|
||||
new Object[] {groupKey, tag, lastModifiedTs, localTagLastModifiedTs});
|
||||
+ "tagLastModifiedTs={},oldTagLastModifiedTs={}", groupKey, tag, lastModifiedTs,
|
||||
localTagLastModifiedTs);
|
||||
updateTagTimeStamp(groupKey, tag, lastModifiedTs);
|
||||
|
||||
} else {
|
||||
@ -469,20 +465,20 @@ public class ConfigCacheService {
|
||||
String switchContent = null;
|
||||
try {
|
||||
if (DatasourceConfiguration.isEmbeddedStorage()) {
|
||||
ConfigInfoBase config = getConfigInfoPersistService().findConfigInfoBase(SwitchService.SWITCH_META_DATAID,
|
||||
ConfigInfoBase config = getConfigInfoPersistService().findConfigInfoBase(SwitchService.SWITCH_META_DATA_ID,
|
||||
"DEFAULT_GROUP");
|
||||
if (config != null) {
|
||||
switchContent = config.getContent();
|
||||
}
|
||||
} else {
|
||||
switchContent = DiskUtil.getConfig(SwitchService.SWITCH_META_DATAID, "DEFAULT_GROUP",
|
||||
switchContent = DiskUtil.getConfig(SwitchService.SWITCH_META_DATA_ID, "DEFAULT_GROUP",
|
||||
StringUtils.EMPTY);
|
||||
}
|
||||
if (switchContent != null) {
|
||||
SwitchService.load(switchContent);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
DUMP_LOG.error("reload fail:" + SwitchService.SWITCH_META_DATAID, e);
|
||||
DUMP_LOG.error("reload fail:" + SwitchService.SWITCH_META_DATA_ID, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -492,7 +488,7 @@ public class ConfigCacheService {
|
||||
* @return return diff result list.
|
||||
*/
|
||||
public static List<String> checkMd5() {
|
||||
List<String> diffList = new ArrayList<String>();
|
||||
List<String> diffList = new ArrayList<>();
|
||||
long startTime = System.currentTimeMillis();
|
||||
for (Entry<String/* groupKey */, CacheItem> entry : CACHE.entrySet()) {
|
||||
String groupKey = entry.getKey();
|
||||
@ -765,7 +761,7 @@ public class ConfigCacheService {
|
||||
*/
|
||||
public static List<String> getBetaIps(String groupKey) {
|
||||
CacheItem item = CACHE.get(groupKey);
|
||||
return (null != item) ? item.getIps4Beta() : Collections.<String>emptyList();
|
||||
return (null != item) ? item.getIps4Beta() : Collections.emptyList();
|
||||
}
|
||||
|
||||
public static long getBetaLastModifiedTs(String groupKey) {
|
||||
|
@ -37,7 +37,7 @@ import static com.alibaba.nacos.config.server.utils.LogUtil.FATAL_LOG;
|
||||
@Service
|
||||
public class SwitchService {
|
||||
|
||||
public static final String SWITCH_META_DATAID = "com.alibaba.nacos.meta.switch";
|
||||
public static final String SWITCH_META_DATA_ID = "com.alibaba.nacos.meta.switch";
|
||||
|
||||
public static final String FIXED_POLLING = "isFixedPolling";
|
||||
|
||||
@ -96,7 +96,7 @@ public class SwitchService {
|
||||
if (!StringUtils.isBlank(line) && !line.startsWith("#")) {
|
||||
String[] array = line.split("=");
|
||||
|
||||
if (array == null || array.length != 2) {
|
||||
if (array.length != 2) {
|
||||
LogUtil.FATAL_LOG.error("corrupt switch record {}", line);
|
||||
continue;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public class DumpConfigHandler extends Subscriber<ConfigDumpEvent> {
|
||||
ClientIpWhiteList.load(content);
|
||||
}
|
||||
|
||||
if (dataId.equals(SwitchService.SWITCH_META_DATAID)) {
|
||||
if (dataId.equals(SwitchService.SWITCH_META_DATA_ID)) {
|
||||
SwitchService.load(content);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class DumpAllProcessor implements NacosTaskProcessor {
|
||||
ClientIpWhiteList.load(cf.getContent());
|
||||
}
|
||||
|
||||
if (cf.getDataId().equals(SwitchService.SWITCH_META_DATAID)) {
|
||||
if (cf.getDataId().equals(SwitchService.SWITCH_META_DATA_ID)) {
|
||||
SwitchService.load(cf.getContent());
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ public class ConfigRowMapperInjector {
|
||||
static {
|
||||
injectConfigRowMapper();
|
||||
}
|
||||
|
||||
|
||||
public ConfigRowMapperInjector() {
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ public interface PersistService {
|
||||
Map<String, Object> configAdvanceInfo, boolean notify);
|
||||
|
||||
/**
|
||||
* insert or update cas..
|
||||
* insert or update cas.
|
||||
*
|
||||
* @param srcIp remote ip
|
||||
* @param srcUser user
|
||||
@ -591,7 +591,7 @@ public interface PersistService {
|
||||
/**
|
||||
* Returns the number of beta configuration items.
|
||||
*
|
||||
* @return number of configuration items..
|
||||
* @return number of configuration items.
|
||||
*/
|
||||
@Deprecated
|
||||
int configInfoBetaCount();
|
||||
@ -599,7 +599,7 @@ public interface PersistService {
|
||||
/**
|
||||
* Returns the number of beta configuration items.
|
||||
*
|
||||
* @return number of configuration items..
|
||||
* @return number of configuration items.
|
||||
*/
|
||||
@Deprecated
|
||||
int configInfoTagCount();
|
||||
@ -703,8 +703,8 @@ public interface PersistService {
|
||||
/**
|
||||
* Query all tag config info for dump task.
|
||||
*
|
||||
* @param pageNo page numbser
|
||||
* @param pageSize page sizxe
|
||||
* @param pageNo page numbers
|
||||
* @param pageSize page size
|
||||
* @return {@link Page} with {@link ConfigInfoWrapper} generation
|
||||
*/
|
||||
@Deprecated
|
||||
@ -1050,19 +1050,19 @@ public interface PersistService {
|
||||
/**
|
||||
* insert tenant info.
|
||||
*
|
||||
* @param kp kp
|
||||
* @param tenantId tenant Id
|
||||
* @param tenantName tenant name
|
||||
* @param tenantDesc tenant description
|
||||
* @param createResoure create resouce
|
||||
* @param time time
|
||||
* @param kp kp
|
||||
* @param tenantId tenant Id
|
||||
* @param tenantName tenant name
|
||||
* @param tenantDesc tenant description
|
||||
* @param createResource create resource
|
||||
* @param time time
|
||||
*/
|
||||
@Deprecated
|
||||
void insertTenantInfoAtomic(String kp, String tenantId, String tenantName, String tenantDesc, String createResoure,
|
||||
void insertTenantInfoAtomic(String kp, String tenantId, String tenantName, String tenantDesc, String createResource,
|
||||
final long time);
|
||||
|
||||
/**
|
||||
* Update tenantInfo showname.
|
||||
* Update tenantInfo show name.
|
||||
*
|
||||
* @param kp kp
|
||||
* @param tenantId tenant Id
|
||||
|
@ -566,7 +566,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
try {
|
||||
ConfigInfoMapper configInfoMapper = mapperManager.findMapper(dataSourceService.getDataSourceType(),
|
||||
TableConstant.CONFIG_INFO);
|
||||
final String sql = configInfoMapper.update(Arrays.asList("md5"),
|
||||
final String sql = configInfoMapper.update(Collections.singletonList("md5"),
|
||||
Arrays.asList("data_id", "group_id", "tenant_id", "gmt_modified"));
|
||||
final Object[] args = new Object[] {md5, dataId, group, tenantTmp, lastTime};
|
||||
|
||||
@ -1501,7 +1501,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
ConfigInfoAggrMapper configInfoAggrMapper = mapperManager.findMapper(dataSourceService.getDataSourceType(),
|
||||
TableConstant.CONFIG_INFO_AGGR);
|
||||
final int startRow = (pageNo - 1) * pageSize;
|
||||
final String sqlCountRows = configInfoAggrMapper.select(Arrays.asList("count(*)"),
|
||||
final String sqlCountRows = configInfoAggrMapper.select(Collections.singletonList("count(*)"),
|
||||
Arrays.asList("data_id", "group_id", "tenant_id"));
|
||||
|
||||
MapperContext context = new MapperContext();
|
||||
@ -1527,7 +1527,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
String sqlFetchRows = "SELECT data_id,group_id,tenant_id,datum_id,app_name,content FROM config_info_aggr WHERE ";
|
||||
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) {
|
||||
if (configKeys.length == 0 && !blacklist) {
|
||||
Page<ConfigInfoAggr> page = new Page<>();
|
||||
page.setTotalCount(0);
|
||||
return page;
|
||||
@ -1753,7 +1753,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
public void removeTagByIdAtomic(long id) {
|
||||
ConfigTagsRelationMapper configTagsRelationMapper = mapperManager.findMapper(
|
||||
dataSourceService.getDataSourceType(), TableConstant.CONFIG_TAGS_RELATION);
|
||||
final String sql = configTagsRelationMapper.delete(Arrays.asList("id"));
|
||||
final String sql = configTagsRelationMapper.delete(Collections.singletonList("id"));
|
||||
final Object[] args = new Object[] {id};
|
||||
EmbeddedStorageContextHolder.addSqlContext(sql, args);
|
||||
}
|
||||
@ -1762,7 +1762,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
public List<String> selectTagByConfig(String dataId, String group, String tenant) {
|
||||
ConfigTagsRelationMapper configTagsRelationMapper = mapperManager.findMapper(
|
||||
dataSourceService.getDataSourceType(), TableConstant.CONFIG_TAGS_RELATION);
|
||||
String sql = configTagsRelationMapper.select(Arrays.asList("tag_name"),
|
||||
String sql = configTagsRelationMapper.select(Collections.singletonList("tag_name"),
|
||||
Arrays.asList("data_id", "group_id", "tenant_id"));
|
||||
return databaseOperate.queryMany(sql, new Object[] {dataId, group, tenant}, String.class);
|
||||
}
|
||||
@ -2022,14 +2022,14 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
|
||||
@Override
|
||||
public void insertTenantInfoAtomic(String kp, String tenantId, String tenantName, String tenantDesc,
|
||||
String createResoure, final long time) {
|
||||
String createResource, final long time) {
|
||||
|
||||
TenantInfoMapper tenantInfoMapper = mapperManager.findMapper(dataSourceService.getDataSourceType(),
|
||||
TableConstant.TENANT_INFO);
|
||||
final String sql = tenantInfoMapper.insert(
|
||||
Arrays.asList("kp", "tenant_id", "tenant_name", "tenant_desc", "create_source", "gmt_create",
|
||||
"gmt_modified"));
|
||||
final Object[] args = new Object[] {kp, tenantId, tenantName, tenantDesc, createResoure, time, time};
|
||||
final Object[] args = new Object[] {kp, tenantId, tenantName, tenantDesc, createResource, time, time};
|
||||
|
||||
EmbeddedStorageContextHolder.addSqlContext(sql, args);
|
||||
|
||||
@ -2330,7 +2330,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
}
|
||||
TenantInfoMapper tenantInfoMapper = mapperManager.findMapper(dataSourceService.getDataSourceType(),
|
||||
TableConstant.TENANT_INFO);
|
||||
String sql = tenantInfoMapper.count(Arrays.asList("tenant_id"));
|
||||
String sql = tenantInfoMapper.count(Collections.singletonList("tenant_id"));
|
||||
Integer result = databaseOperate.queryOne(sql, new String[] {tenantId}, Integer.class);
|
||||
if (result == null) {
|
||||
return 0;
|
||||
|
@ -289,7 +289,12 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
@Override
|
||||
public boolean updateConfigInfoCas(final ConfigInfo configInfo, final String srcIp, final String srcUser,
|
||||
final Timestamp time, final Map<String, Object> configAdvanceInfo, final boolean notify) {
|
||||
return tjt.execute(status -> {
|
||||
/*
|
||||
If the appName passed by the user is not empty, use the persistent user's appName,
|
||||
otherwise use db; when emptying appName, you need to pass an empty string
|
||||
*/
|
||||
// delete all tags and then recreate
|
||||
return Boolean.TRUE.equals(tjt.execute(status -> {
|
||||
try {
|
||||
ConfigInfo oldConfigInfo = findConfigInfo(configInfo.getDataId(), configInfo.getGroup(),
|
||||
configInfo.getTenant());
|
||||
@ -318,7 +323,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
throw e;
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -722,7 +727,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
if (result == null) {
|
||||
throw new IllegalArgumentException("configInfoBetaCount error");
|
||||
}
|
||||
return result.intValue();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1012,7 +1017,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
if (result == null) {
|
||||
throw new IllegalArgumentException("configInfoCount error");
|
||||
}
|
||||
return result.intValue();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1026,7 +1031,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
if (result == null) {
|
||||
throw new IllegalArgumentException("configInfoCount error");
|
||||
}
|
||||
return result.intValue();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1038,7 +1043,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
if (result == null) {
|
||||
throw new IllegalArgumentException("configInfoBetaCount error");
|
||||
}
|
||||
return result.intValue();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1050,7 +1055,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
if (result == null) {
|
||||
throw new IllegalArgumentException("configInfoBetaCount error");
|
||||
}
|
||||
return result.intValue();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1077,11 +1082,11 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
ConfigInfoAggrMapper configInfoAggrMapper = mapperManager.findMapper(dataSourceService.getDataSourceType(),
|
||||
TableConstant.CONFIG_INFO_AGGR);
|
||||
String sql = configInfoAggrMapper.count(Arrays.asList("data_id", "group_id", "tenant_id"));
|
||||
Integer result = jt.queryForObject(sql, Integer.class, new Object[] {dataId, group, tenantTmp});
|
||||
Integer result = jt.queryForObject(sql, Integer.class, dataId, group, tenantTmp);
|
||||
if (result == null) {
|
||||
throw new IllegalArgumentException("aggrConfigInfoCount error");
|
||||
}
|
||||
return result.intValue();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1108,7 +1113,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
if (result == null) {
|
||||
throw new IllegalArgumentException("aggrConfigInfoCount error");
|
||||
}
|
||||
return result.intValue();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1265,7 +1270,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
String sqlFetchRows = "SELECT id,data_id,group_id,tenant_id,app_name,content FROM config_info WHERE ";
|
||||
StringBuilder where = new StringBuilder(" 1=1 ");
|
||||
// Whitelist, please leave the synchronization condition empty, there is no configuration that meets the conditions
|
||||
if (configKeys.length == 0 && blacklist == false) {
|
||||
if (configKeys.length == 0 && !blacklist) {
|
||||
Page<ConfigInfo> page = new Page<>();
|
||||
page.setTotalCount(0);
|
||||
return page;
|
||||
@ -1506,7 +1511,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
ConfigInfoAggrMapper configInfoAggrMapper = mapperManager.findMapper(dataSourceService.getDataSourceType(),
|
||||
TableConstant.CONFIG_INFO_AGGR);
|
||||
final int startRow = (pageNo - 1) * pageSize;
|
||||
String sqlCountRows = configInfoAggrMapper.select(Arrays.asList("count(*)"),
|
||||
String sqlCountRows = configInfoAggrMapper.select(Collections.singletonList("count(*)"),
|
||||
Arrays.asList("data_id", "group_id", "tenant_id"));
|
||||
|
||||
MapperContext context = new MapperContext();
|
||||
@ -1538,7 +1543,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
String sqlFetchRows = "SELECT data_id,group_id,tenant_id,datum_id,app_name,content FROM config_info_aggr WHERE ";
|
||||
StringBuilder where = new StringBuilder(" 1=1 ");
|
||||
// Whitelist, please leave the synchronization condition empty, there is no configuration that meets the conditions
|
||||
if (configKeys.length == 0 && blacklist == false) {
|
||||
if (configKeys.length == 0 && !blacklist) {
|
||||
Page<ConfigInfoAggr> page = new Page<>();
|
||||
page.setTotalCount(0);
|
||||
return page;
|
||||
@ -1659,8 +1664,6 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
|
||||
try {
|
||||
return this.jt.queryForList(sql, new Object[] {dataId, groupId, content}, String.class);
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
return null;
|
||||
} catch (IncorrectResultSizeDataAccessException e) {
|
||||
return null;
|
||||
} catch (CannotGetJdbcConnectionException e) {
|
||||
@ -1839,7 +1842,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
try {
|
||||
ConfigTagsRelationMapper configTagsRelationMapper = mapperManager.findMapper(
|
||||
dataSourceService.getDataSourceType(), TableConstant.CONFIG_TAGS_RELATION);
|
||||
jt.update(configTagsRelationMapper.delete(Arrays.asList("id")), id);
|
||||
jt.update(configTagsRelationMapper.delete(Collections.singletonList("id")), id);
|
||||
} catch (CannotGetJdbcConnectionException e) {
|
||||
LogUtil.FATAL_LOG.error("[db-error] " + e.toString(), e);
|
||||
throw e;
|
||||
@ -1850,12 +1853,10 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
public List<String> selectTagByConfig(String dataId, String group, String tenant) {
|
||||
ConfigTagsRelationMapper configTagsRelationMapper = mapperManager.findMapper(
|
||||
dataSourceService.getDataSourceType(), TableConstant.CONFIG_TAGS_RELATION);
|
||||
String sql = configTagsRelationMapper.select(Arrays.asList("tag_name"),
|
||||
String sql = configTagsRelationMapper.select(Collections.singletonList("tag_name"),
|
||||
Arrays.asList("data_id", "group_id", "tenant_id"));
|
||||
try {
|
||||
return jt.queryForList(sql, new Object[] {dataId, group, tenant}, String.class);
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
return null;
|
||||
} catch (IncorrectResultSizeDataAccessException e) {
|
||||
return null;
|
||||
} catch (CannotGetJdbcConnectionException e) {
|
||||
@ -2033,7 +2034,9 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
configTagsTmp.append(',').append(configTag);
|
||||
}
|
||||
}
|
||||
configAdvance.setConfigTags(configTagsTmp.toString());
|
||||
if (configAdvance != null) {
|
||||
configAdvance.setConfigTags(configTagsTmp.toString());
|
||||
}
|
||||
}
|
||||
return configAdvance;
|
||||
} catch (EmptyResultDataAccessException e) { // Indicates that the data does not exist, returns null
|
||||
@ -2065,7 +2068,9 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
configTagsTmp.append(',').append(configTag);
|
||||
}
|
||||
}
|
||||
configAdvance.setConfigTags(configTagsTmp.toString());
|
||||
if (configAdvance != null) {
|
||||
configAdvance.setConfigTags(configTagsTmp.toString());
|
||||
}
|
||||
}
|
||||
return configAdvance;
|
||||
} catch (EmptyResultDataAccessException e) { // Indicates that the data does not exist, returns null
|
||||
@ -2163,13 +2168,13 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
|
||||
@Override
|
||||
public void insertTenantInfoAtomic(String kp, String tenantId, String tenantName, String tenantDesc,
|
||||
String createResoure, final long time) {
|
||||
String createResource, final long time) {
|
||||
try {
|
||||
TenantInfoMapper tenantInfoMapper = mapperManager.findMapper(dataSourceService.getDataSourceType(),
|
||||
TableConstant.TENANT_INFO);
|
||||
jt.update(tenantInfoMapper.insert(
|
||||
Arrays.asList("kp", "tenant_id", "tenant_name", "tenant_desc", "create_source", "gmt_create",
|
||||
"gmt_modified")), kp, tenantId, tenantName, tenantDesc, createResoure, time, time);
|
||||
"gmt_modified")), kp, tenantId, tenantName, tenantDesc, createResource, time, time);
|
||||
} catch (DataAccessException e) {
|
||||
LogUtil.FATAL_LOG.error("[db-error] " + e.toString(), e);
|
||||
throw e;
|
||||
@ -2476,12 +2481,12 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
}
|
||||
TenantInfoMapper tenantInfoMapper = mapperManager.findMapper(dataSourceService.getDataSourceType(),
|
||||
TableConstant.TENANT_INFO);
|
||||
String sql = tenantInfoMapper.count(Arrays.asList("tenant_id"));
|
||||
String sql = tenantInfoMapper.count(Collections.singletonList("tenant_id"));
|
||||
Integer result = this.jt.queryForObject(sql, new String[] {tenantId}, Integer.class);
|
||||
if (result == null) {
|
||||
return 0;
|
||||
}
|
||||
return result.intValue();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user