To slightly improve performance, this commit switches to StringBuilder.append(char) instead of StringBuilder.append(String) whenever we append a single character to a StringBuilder. (#6300)
This commit is contained in:
parent
f326a0c543
commit
cdc276e829
@ -103,8 +103,8 @@ public class AddressServerGeneratorManager {
|
||||
|
||||
StringBuilder ips = new StringBuilder();
|
||||
instanceList.forEach(instance -> {
|
||||
ips.append(instance.getIp()).append(":").append(instance.getPort());
|
||||
ips.append("\n");
|
||||
ips.append(instance.getIp()).append(':').append(instance.getPort());
|
||||
ips.append('\n');
|
||||
});
|
||||
|
||||
return ips.toString();
|
||||
|
@ -124,9 +124,9 @@ public class SimpleHttpTestUtils {
|
||||
if (paramMap != null) {
|
||||
for (Map.Entry<String, String> element : paramMap.entrySet()) {
|
||||
params.append(element.getKey());
|
||||
params.append("=");
|
||||
params.append('=');
|
||||
params.append(URLEncoder.encode(element.getValue(), REQUEST_ENCODING));
|
||||
params.append("&");
|
||||
params.append('&');
|
||||
}
|
||||
|
||||
if (params.length() > 0) {
|
||||
|
@ -101,7 +101,7 @@ public class EnvUtil {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (String string : list) {
|
||||
result.append(string);
|
||||
result.append(",");
|
||||
result.append(',');
|
||||
}
|
||||
return result.substring(0, result.length() - 1);
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ public final class HttpUtils {
|
||||
if (subPath.startsWith("/")) {
|
||||
sb.append(subPath);
|
||||
} else {
|
||||
sb.append("/").append(subPath);
|
||||
sb.append('/').append(subPath);
|
||||
}
|
||||
} else {
|
||||
if (subPath.startsWith("/")) {
|
||||
@ -199,9 +199,9 @@ public final class HttpUtils {
|
||||
continue;
|
||||
}
|
||||
|
||||
sb.append(entry.getKey()).append("=");
|
||||
sb.append(entry.getKey()).append('=');
|
||||
sb.append(URLEncoder.encode(entry.getValue(), encoding));
|
||||
sb.append("&");
|
||||
sb.append('&');
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
@ -222,10 +222,10 @@ public final class HttpUtils {
|
||||
}
|
||||
|
||||
for (Iterator<String> iter = paramValues.iterator(); iter.hasNext(); ) {
|
||||
sb.append(iter.next()).append("=");
|
||||
sb.append(iter.next()).append('=');
|
||||
sb.append(URLEncoder.encode(iter.next(), encoding));
|
||||
if (iter.hasNext()) {
|
||||
sb.append("&");
|
||||
sb.append('&');
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
|
@ -106,10 +106,10 @@ public class Query {
|
||||
for (Map.Entry<String, Object> entry : entrySet) {
|
||||
try {
|
||||
if (null != entry.getValue()) {
|
||||
urlBuilder.append(entry.getKey()).append("=")
|
||||
urlBuilder.append(entry.getKey()).append('=')
|
||||
.append(URLEncoder.encode(String.valueOf(entry.getValue()), DEFAULT_ENC));
|
||||
if (i > 1) {
|
||||
urlBuilder.append("&");
|
||||
urlBuilder.append('&');
|
||||
}
|
||||
}
|
||||
i--;
|
||||
|
@ -104,7 +104,7 @@ public class NacosExecuteTaskExecuteEngine extends AbstractNacosTaskExecuteEngin
|
||||
public String workersStatus() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (TaskExecuteWorker worker : executeWorkers) {
|
||||
sb.append(worker.status()).append("\n");
|
||||
sb.append(worker.status()).append('\n');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class ExceptionUtil {
|
||||
StringBuilder strBuilder = new StringBuilder();
|
||||
|
||||
while (cause != null && !StringUtils.isEmpty(cause.getMessage())) {
|
||||
strBuilder.append("caused: ").append(cause.getMessage()).append(";");
|
||||
strBuilder.append("caused: ").append(cause.getMessage()).append(';');
|
||||
cause = cause.getCause();
|
||||
}
|
||||
|
||||
|
@ -112,13 +112,13 @@ public class TypeUtils {
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
|
||||
buf.append(raw.getName());
|
||||
buf.append("<");
|
||||
buf.append('<');
|
||||
buf.append(typeArguments[0].getTypeName());
|
||||
for (int i = 1; i < typeArguments.length; i++) {
|
||||
buf.append(", ");
|
||||
buf.append(typeArguments[i].getTypeName());
|
||||
}
|
||||
buf.append(">");
|
||||
buf.append('>');
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
|
@ -71,13 +71,13 @@ public class ConfigResourceParser implements ResourceParser {
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(groupName)) {
|
||||
sb.append(Resource.SPLITTER).append("*");
|
||||
sb.append(Resource.SPLITTER).append('*');
|
||||
} else {
|
||||
sb.append(Resource.SPLITTER).append(groupName);
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(dataId)) {
|
||||
sb.append(Resource.SPLITTER).append(AUTH_CONFIG_PREFIX).append("*");
|
||||
sb.append(Resource.SPLITTER).append(AUTH_CONFIG_PREFIX).append('*');
|
||||
} else {
|
||||
sb.append(Resource.SPLITTER).append(AUTH_CONFIG_PREFIX).append(dataId);
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ public class ConfigController {
|
||||
metaDataId = metaDataId.substring(0, metaDataId.lastIndexOf(".")) + "~" + metaDataId
|
||||
.substring(metaDataId.lastIndexOf(".") + 1);
|
||||
}
|
||||
metaData.append(ci.getGroup()).append(".").append(metaDataId).append(".app=")
|
||||
metaData.append(ci.getGroup()).append('.').append(metaDataId).append(".app=")
|
||||
// Fixed use of "\r\n" here
|
||||
.append(ci.getAppName()).append("\r\n");
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ public final class TaskManager extends NacosDelayTaskExecuteEngine implements Ta
|
||||
public String getTaskInfos() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Object taskType : getAllProcessorKey()) {
|
||||
sb.append(taskType).append(":");
|
||||
sb.append(taskType).append(':');
|
||||
AbstractDelayTask task = this.tasks.get(taskType);
|
||||
if (task != null) {
|
||||
sb.append(new Date(task.getLastProcessTime()).toString());
|
||||
|
@ -172,7 +172,7 @@ public class ConfigSubService {
|
||||
try {
|
||||
StringBuilder paramUrl = new StringBuilder();
|
||||
for (Map.Entry<String, String> param : params.entrySet()) {
|
||||
paramUrl.append("&").append(param.getKey()).append("=")
|
||||
paramUrl.append('&').append(param.getKey()).append('=')
|
||||
.append(URLEncoder.encode(param.getValue(), Constants.ENCODE));
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ public class SwitchService {
|
||||
String value = entry.getValue();
|
||||
sb.append(split);
|
||||
sb.append(key);
|
||||
sb.append("=");
|
||||
sb.append('=');
|
||||
sb.append(value);
|
||||
split = "; ";
|
||||
}
|
||||
|
@ -710,7 +710,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
final String tenantTmp = StringUtils.isBlank(tenant) ? StringUtils.EMPTY : tenant;
|
||||
final StringBuilder datumString = new StringBuilder();
|
||||
for (String datum : datumList) {
|
||||
datumString.append("'").append(datum).append("',");
|
||||
datumString.append('\'').append(datum).append("',");
|
||||
}
|
||||
datumString.deleteCharAt(datumString.length() - 1);
|
||||
final String sql =
|
||||
@ -862,7 +862,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
if (i != 0) {
|
||||
sql.append(", ");
|
||||
}
|
||||
sql.append("?");
|
||||
sql.append('?');
|
||||
paramList.add(tagArr[i]);
|
||||
}
|
||||
sql.append(") ");
|
||||
@ -954,8 +954,8 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
sqlCount.append(", ");
|
||||
sql.append(", ");
|
||||
}
|
||||
sqlCount.append("?");
|
||||
sql.append("?");
|
||||
sqlCount.append('?');
|
||||
sql.append('?');
|
||||
paramList.add(tagArr[i]);
|
||||
}
|
||||
sqlCount.append(") ");
|
||||
@ -1016,7 +1016,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
if (i != 0) {
|
||||
where.append(", ");
|
||||
}
|
||||
where.append("?");
|
||||
where.append('?');
|
||||
paramList.add(tagArr[i]);
|
||||
}
|
||||
where.append(") ");
|
||||
@ -1102,8 +1102,8 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
sqlCount.append(", ");
|
||||
sql.append(", ");
|
||||
}
|
||||
sqlCount.append("?");
|
||||
sql.append("?");
|
||||
sqlCount.append('?');
|
||||
sql.append('?');
|
||||
paramList.add(tagArr[i]);
|
||||
}
|
||||
sqlCount.append(") ");
|
||||
@ -1166,8 +1166,8 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
sqlCount.append(", ");
|
||||
sql.append(", ");
|
||||
}
|
||||
sqlCount.append("?");
|
||||
sql.append("?");
|
||||
sqlCount.append('?');
|
||||
sql.append('?');
|
||||
paramList.add(tagArr[i]);
|
||||
}
|
||||
sqlCount.append(") ");
|
||||
@ -1293,9 +1293,9 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
if (i > 0) {
|
||||
sql.append(", ");
|
||||
}
|
||||
sql.append("?");
|
||||
sql.append('?');
|
||||
}
|
||||
sql.append(")");
|
||||
sql.append(')');
|
||||
|
||||
List<Object> objectList = Lists.<Object>newArrayList(dataId, group, tenantTmp);
|
||||
objectList.addAll(datumIds);
|
||||
@ -1457,9 +1457,9 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
dataIds.subList(i, Math.min(i + subQueryLimit, dataIds.size())));
|
||||
|
||||
for (int j = 0; j < params.size(); j++) {
|
||||
subQuerySql.append("?");
|
||||
subQuerySql.append('?');
|
||||
if (j != params.size() - 1) {
|
||||
subQuerySql.append(",");
|
||||
subQuerySql.append(',');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1553,7 +1553,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
where.append(" AND ");
|
||||
}
|
||||
|
||||
where.append("(");
|
||||
where.append('(');
|
||||
boolean isFirstSub = true;
|
||||
if (!StringUtils.isBlank(dataId)) {
|
||||
where.append(" data_id NOT LIKE ? ");
|
||||
@ -1584,7 +1584,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
} else {
|
||||
where.append(" OR ");
|
||||
}
|
||||
where.append("(");
|
||||
where.append('(');
|
||||
boolean isFirstSub = true;
|
||||
if (!StringUtils.isBlank(dataId)) {
|
||||
where.append(" data_id LIKE ? ");
|
||||
@ -1659,7 +1659,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
if (i != 0) {
|
||||
where.append(", ");
|
||||
}
|
||||
where.append("?");
|
||||
where.append('?');
|
||||
params.add(tagArr[i]);
|
||||
}
|
||||
where.append(") ");
|
||||
@ -1787,7 +1787,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
where.append(" AND ");
|
||||
}
|
||||
|
||||
where.append("(");
|
||||
where.append('(');
|
||||
boolean isFirstSub = true;
|
||||
if (!StringUtils.isBlank(dataId)) {
|
||||
where.append(" data_id NOT LIKE ? ");
|
||||
@ -1818,7 +1818,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
} else {
|
||||
where.append(" OR ");
|
||||
}
|
||||
where.append("(");
|
||||
where.append('(');
|
||||
boolean isFirstSub = true;
|
||||
if (!StringUtils.isBlank(dataId)) {
|
||||
where.append(" data_id LIKE ? ");
|
||||
@ -2011,7 +2011,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
if (i != 0) {
|
||||
sql.append(", ");
|
||||
}
|
||||
sql.append("?");
|
||||
sql.append('?');
|
||||
paramList.add(Long.parseLong(tagArr[i]));
|
||||
}
|
||||
sql.append(") ");
|
||||
@ -2095,7 +2095,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
if (i != 0) {
|
||||
sql.append(", ");
|
||||
}
|
||||
sql.append("?");
|
||||
sql.append('?');
|
||||
paramList.add(Long.parseLong(tagArr[i]));
|
||||
}
|
||||
sql.append(") ");
|
||||
@ -2118,7 +2118,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
if (configTagsTmp.length() == 0) {
|
||||
configTagsTmp.append(configTag);
|
||||
} else {
|
||||
configTagsTmp.append(",").append(configTag);
|
||||
configTagsTmp.append(',').append(configTag);
|
||||
}
|
||||
}
|
||||
configAdvance.setConfigTags(configTagsTmp.toString());
|
||||
@ -2145,7 +2145,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
if (configTagsTmp.length() == 0) {
|
||||
configTagsTmp.append(configTag);
|
||||
} else {
|
||||
configTagsTmp.append(",").append(configTag);
|
||||
configTagsTmp.append(',').append(configTag);
|
||||
}
|
||||
}
|
||||
configAdvance.setConfigTags(configTagsTmp.toString());
|
||||
@ -2433,7 +2433,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
if (i != 0) {
|
||||
where.append(", ");
|
||||
}
|
||||
where.append("?");
|
||||
where.append('?');
|
||||
paramList.add(ids.get(i));
|
||||
}
|
||||
where.append(") ");
|
||||
|
@ -615,7 +615,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
final String tenantTmp = StringUtils.isBlank(tenant) ? StringUtils.EMPTY : tenant;
|
||||
final StringBuilder datumString = new StringBuilder();
|
||||
for (String datum : datumList) {
|
||||
datumString.append("'").append(datum).append("',");
|
||||
datumString.append('\'').append(datum).append("',");
|
||||
}
|
||||
datumString.deleteCharAt(datumString.length() - 1);
|
||||
final String sql =
|
||||
@ -813,7 +813,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
if (i != 0) {
|
||||
sql.append(", ");
|
||||
}
|
||||
sql.append("?");
|
||||
sql.append('?');
|
||||
paramList.add(tagArr[i]);
|
||||
}
|
||||
sql.append(") ");
|
||||
@ -942,8 +942,8 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
sqlCount.append(", ");
|
||||
sql.append(", ");
|
||||
}
|
||||
sqlCount.append("?");
|
||||
sql.append("?");
|
||||
sqlCount.append('?');
|
||||
sql.append('?');
|
||||
paramList.add(tagArr[i]);
|
||||
}
|
||||
sqlCount.append(") ");
|
||||
@ -1008,7 +1008,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
if (i != 0) {
|
||||
where.append(", ");
|
||||
}
|
||||
where.append("?");
|
||||
where.append('?');
|
||||
paramList.add(tagArr[i]);
|
||||
}
|
||||
where.append(") ");
|
||||
@ -1109,8 +1109,8 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
sqlCount.append(", ");
|
||||
sql.append(", ");
|
||||
}
|
||||
sqlCount.append("?");
|
||||
sql.append("?");
|
||||
sqlCount.append('?');
|
||||
sql.append('?');
|
||||
paramList.add(tagArr[i]);
|
||||
}
|
||||
sqlCount.append(") ");
|
||||
@ -1181,8 +1181,8 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
sqlCount.append(", ");
|
||||
sql.append(", ");
|
||||
}
|
||||
sqlCount.append("?");
|
||||
sql.append("?");
|
||||
sqlCount.append('?');
|
||||
sql.append('?');
|
||||
paramList.add(tagArr[i]);
|
||||
}
|
||||
sqlCount.append(") ");
|
||||
@ -1306,9 +1306,9 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
if (i > 0) {
|
||||
sql.append(", ");
|
||||
}
|
||||
sql.append("?");
|
||||
sql.append('?');
|
||||
}
|
||||
sql.append(")");
|
||||
sql.append(')');
|
||||
|
||||
List<Object> objectList = Lists.<Object>newArrayList(dataId, group, tenantTmp);
|
||||
objectList.addAll(datumIds);
|
||||
@ -1499,9 +1499,9 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
dataIds.subList(i, i + subQueryLimit < dataIds.size() ? i + subQueryLimit : dataIds.size()));
|
||||
|
||||
for (int j = 0; j < params.size(); j++) {
|
||||
subQuerySql.append("?");
|
||||
subQuerySql.append('?');
|
||||
if (j != params.size() - 1) {
|
||||
subQuerySql.append(",");
|
||||
subQuerySql.append(',');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1601,7 +1601,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
where.append(" AND ");
|
||||
}
|
||||
|
||||
where.append("(");
|
||||
where.append('(');
|
||||
boolean isFirstSub = true;
|
||||
if (!StringUtils.isBlank(dataId)) {
|
||||
where.append(" data_id NOT LIKE ? ");
|
||||
@ -1632,7 +1632,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
} else {
|
||||
where.append(" OR ");
|
||||
}
|
||||
where.append("(");
|
||||
where.append('(');
|
||||
boolean isFirstSub = true;
|
||||
if (!StringUtils.isBlank(dataId)) {
|
||||
where.append(" data_id LIKE ? ");
|
||||
@ -1709,7 +1709,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
if (i != 0) {
|
||||
where.append(", ");
|
||||
}
|
||||
where.append("?");
|
||||
where.append('?');
|
||||
params.add(tagArr[i]);
|
||||
}
|
||||
where.append(") ");
|
||||
@ -1868,7 +1868,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
where.append(" AND ");
|
||||
}
|
||||
|
||||
where.append("(");
|
||||
where.append('(');
|
||||
boolean isFirstSub = true;
|
||||
if (!StringUtils.isBlank(dataId)) {
|
||||
where.append(" data_id NOT LIKE ? ");
|
||||
@ -1899,7 +1899,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
} else {
|
||||
where.append(" OR ");
|
||||
}
|
||||
where.append("(");
|
||||
where.append('(');
|
||||
boolean isFirstSub = true;
|
||||
if (!StringUtils.isBlank(dataId)) {
|
||||
where.append(" data_id LIKE ? ");
|
||||
@ -2187,7 +2187,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
if (i != 0) {
|
||||
sql.append(", ");
|
||||
}
|
||||
sql.append("?");
|
||||
sql.append('?');
|
||||
paramList.add(Long.parseLong(tagArr[i]));
|
||||
}
|
||||
sql.append(") ");
|
||||
@ -2273,7 +2273,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
if (i != 0) {
|
||||
sql.append(", ");
|
||||
}
|
||||
sql.append("?");
|
||||
sql.append('?');
|
||||
paramList.add(Long.parseLong(tagArr[i]));
|
||||
}
|
||||
sql.append(") ");
|
||||
@ -2301,7 +2301,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
if (configTagsTmp.length() == 0) {
|
||||
configTagsTmp.append(configTag);
|
||||
} else {
|
||||
configTagsTmp.append(",").append(configTag);
|
||||
configTagsTmp.append(',').append(configTag);
|
||||
}
|
||||
}
|
||||
configAdvance.setConfigTags(configTagsTmp.toString());
|
||||
@ -2331,7 +2331,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
if (configTagsTmp.length() == 0) {
|
||||
configTagsTmp.append(configTag);
|
||||
} else {
|
||||
configTagsTmp.append(",").append(configTag);
|
||||
configTagsTmp.append(',').append(configTag);
|
||||
}
|
||||
}
|
||||
configAdvance.setConfigTags(configTagsTmp.toString());
|
||||
@ -2666,7 +2666,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
if (i != 0) {
|
||||
where.append(", ");
|
||||
}
|
||||
where.append("?");
|
||||
where.append('?');
|
||||
paramList.add(ids.get(i));
|
||||
}
|
||||
where.append(") ");
|
||||
|
@ -73,9 +73,9 @@ public class MD5Util {
|
||||
for (String groupKey : changedGroupKeys) {
|
||||
String[] dataIdGroupId = GroupKey2.parseKey(groupKey);
|
||||
sb.append(dataIdGroupId[0]);
|
||||
sb.append(":");
|
||||
sb.append(':');
|
||||
sb.append(dataIdGroupId[1]);
|
||||
sb.append(";");
|
||||
sb.append(';');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class RegexParser {
|
||||
throw new NullPointerException("regex string can't be null");
|
||||
}
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append("^");
|
||||
result.append('^');
|
||||
for (int i = 0; i < regex.length(); i++) {
|
||||
char ch = regex.charAt(i);
|
||||
if (isAsciiAlphanumeric(ch)) {
|
||||
@ -63,7 +63,7 @@ public class RegexParser {
|
||||
result.append("\\" + ch);
|
||||
}
|
||||
}
|
||||
result.append("$");
|
||||
result.append('$');
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class SimpleFlowData {
|
||||
|
||||
for (int i = 0; i < slotCount; i++) {
|
||||
if (i > 0) {
|
||||
sb.append(" ");
|
||||
sb.append(' ');
|
||||
}
|
||||
sb.append(this.data[(i + index) % slotCount].get());
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ public class MemberUtil {
|
||||
public static void syncToFile(Collection<Member> members) {
|
||||
try {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("#").append(LocalDateTime.now()).append(StringUtils.LF);
|
||||
builder.append('#').append(LocalDateTime.now()).append(StringUtils.LF);
|
||||
for (String member : simpleMembers(members)) {
|
||||
builder.append(member).append(StringUtils.LF);
|
||||
}
|
||||
|
@ -214,10 +214,10 @@ public class TpsMonitorManager extends Subscriber<TpsControlRuleChangeEvent> {
|
||||
}
|
||||
String point = entry.getKey();
|
||||
tempSecond = pointSlot.time;
|
||||
stringBuilder.append(point).append("|").append("point|").append(value.getTpsRecorder().period)
|
||||
.append("|").append(formatString).append("|")
|
||||
.append(pointSlot.getCountHolder(point).count.get()).append("|")
|
||||
.append(pointSlot.getCountHolder(point).interceptedCount.get()).append("\n");
|
||||
stringBuilder.append(point).append('|').append("point|").append(value.getTpsRecorder().period)
|
||||
.append('|').append(formatString).append('|')
|
||||
.append(pointSlot.getCountHolder(point).count.get()).append('|')
|
||||
.append(pointSlot.getCountHolder(point).interceptedCount.get()).append('\n');
|
||||
for (Map.Entry<String, TpsRecorder> monitorKeyEntry : value.monitorKeysRecorder.entrySet()) {
|
||||
String monitorPattern = monitorKeyEntry.getKey();
|
||||
TpsRecorder ipRecord = monitorKeyEntry.getValue();
|
||||
@ -241,18 +241,18 @@ public class TpsMonitorManager extends Subscriber<TpsControlRuleChangeEvent> {
|
||||
if (ipRecord.isProtoModel()) {
|
||||
Map<String, TpsRecorder.SlotCountHolder> keySlots = ((TpsRecorder.MultiKeyTpsSlot) keySlot).keySlots;
|
||||
for (Map.Entry<String, TpsRecorder.SlotCountHolder> slotCountHolder : keySlots.entrySet()) {
|
||||
stringBuilder.append(point).append("|").append(monitorPattern).append("|")
|
||||
.append(ipRecord.period).append("|").append(timeFormatOfSecond).append("|")
|
||||
.append(slotCountHolder.getKey()).append("|")
|
||||
.append(slotCountHolder.getValue().count).append("|")
|
||||
.append(slotCountHolder.getValue().interceptedCount).append("\n");
|
||||
stringBuilder.append(point).append('|').append(monitorPattern).append('|')
|
||||
.append(ipRecord.period).append('|').append(timeFormatOfSecond).append('|')
|
||||
.append(slotCountHolder.getKey()).append('|')
|
||||
.append(slotCountHolder.getValue().count).append('|')
|
||||
.append(slotCountHolder.getValue().interceptedCount).append('\n');
|
||||
}
|
||||
|
||||
} else {
|
||||
stringBuilder.append(point).append("|").append(monitorPattern).append("|")
|
||||
.append(ipRecord.period).append("|").append(timeFormatOfSecond).append("|")
|
||||
.append(keySlot.getCountHolder(point).count.get()).append("|")
|
||||
.append(keySlot.getCountHolder(point).interceptedCount.get()).append("\n");
|
||||
stringBuilder.append(point).append('|').append(monitorPattern).append('|')
|
||||
.append(ipRecord.period).append('|').append(timeFormatOfSecond).append('|')
|
||||
.append(keySlot.getCountHolder(point).count.get()).append('|')
|
||||
.append(keySlot.getCountHolder(point).interceptedCount.get()).append('\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class Instances implements Record {
|
||||
ip.getIp() + ":" + ip.getPort() + "_" + ip.getWeight() + "_" + ip.isHealthy() + "_" + ip.isEnabled()
|
||||
+ "_" + ip.getClusterName() + "_" + convertMap2String(ip.getMetadata());
|
||||
sb.append(string);
|
||||
sb.append(",");
|
||||
sb.append(',');
|
||||
}
|
||||
|
||||
return MD5Utils.md5Hex(sb.toString(), Constants.ENCODE);
|
||||
@ -96,9 +96,9 @@ public class Instances implements Record {
|
||||
Collections.sort(keys);
|
||||
for (String key : keys) {
|
||||
sb.append(key);
|
||||
sb.append(":");
|
||||
sb.append(':');
|
||||
sb.append(map.get(key));
|
||||
sb.append(",");
|
||||
sb.append(',');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
for (Instance instance : allIPs()) {
|
||||
stringBuilder.append(instance.toIpAddr()).append("_").append(instance.isHealthy()).append(",");
|
||||
stringBuilder.append(instance.toIpAddr()).append('_').append(instance.isHealthy()).append(',');
|
||||
}
|
||||
|
||||
Loggers.EVT_LOG.info("[IP-UPDATED] namespace: {}, service: {}, ips: {}", getNamespaceId(), getName(),
|
||||
@ -560,7 +560,7 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement
|
||||
String string = ip.getIp() + ":" + ip.getPort() + "_" + ip.getWeight() + "_" + ip.isHealthy() + "_" + ip
|
||||
.getClusterName();
|
||||
ipsString.append(string);
|
||||
ipsString.append(",");
|
||||
ipsString.append(',');
|
||||
}
|
||||
|
||||
checksum = MD5Utils.md5Hex(ipsString.toString(), Constants.ENCODE);
|
||||
|
@ -335,7 +335,7 @@ public class ServiceManager implements RecordListener<Service> {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
List<Instance> allIps = service.allIPs();
|
||||
for (Instance instance : allIps) {
|
||||
stringBuilder.append(instance.toIpAddr()).append("_").append(instance.isHealthy()).append(",");
|
||||
stringBuilder.append(instance.toIpAddr()).append('_').append(instance.isHealthy()).append(',');
|
||||
}
|
||||
Loggers.EVT_LOG
|
||||
.debug("[HEALTH-STATUS-UPDATED] namespace: {}, service: {}, ips: {}", service.getNamespaceId(),
|
||||
|
@ -62,7 +62,7 @@ public class NamingEventPublisherFactory implements EventPublisherFactory {
|
||||
public String getAllPublisherStatues() {
|
||||
StringBuilder result = new StringBuilder("Naming event publisher statues:\n");
|
||||
for (NamingEventPublisher each : publisher.values()) {
|
||||
result.append("\t").append(each.getStatus()).append("\n");
|
||||
result.append('\t').append(each.getStatus()).append('\n');
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ public class NamingProxy {
|
||||
public String toUrl() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String key : params.keySet()) {
|
||||
sb.append(key).append("=").append(params.get(key)).append("&");
|
||||
sb.append(key).append('=').append(params.get(key)).append('&');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -74,13 +74,13 @@ public class NamingResourceParser implements ResourceParser {
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(groupName)) {
|
||||
sb.append(Resource.SPLITTER).append("*");
|
||||
sb.append(Resource.SPLITTER).append('*');
|
||||
} else {
|
||||
sb.append(Resource.SPLITTER).append(groupName);
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(serviceName)) {
|
||||
sb.append(Resource.SPLITTER).append(AUTH_NAMING_PREFIX).append("*");
|
||||
sb.append(Resource.SPLITTER).append(AUTH_NAMING_PREFIX).append('*');
|
||||
} else {
|
||||
sb.append(Resource.SPLITTER).append(AUTH_NAMING_PREFIX).append(serviceName);
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public class NamingBase extends HttpClient4Test {
|
||||
sb.append("jinhan");
|
||||
for (int i = 0; i < 2; i++) {
|
||||
sb.append(RandomUtils.getStringWithNumAndCha(5));
|
||||
sb.append(".");
|
||||
sb.append('.');
|
||||
}
|
||||
int i = RandomUtils.getIntegerBetween(0, 2);
|
||||
if (i == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user