mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
局部变量线程安全,优先使用StringBuilder替换StringBuffer (#4472)
Co-authored-by: 夏亮 <xialiang@newerabc.com>
This commit is contained in:
@@ -107,11 +107,11 @@ public class AviaterRegexFilter {
|
|||||||
private List<String> completionPattern(List<String> patterns) {
|
private List<String> completionPattern(List<String> patterns) {
|
||||||
List<String> result = new ArrayList<>();
|
List<String> result = new ArrayList<>();
|
||||||
for (String pattern : patterns) {
|
for (String pattern : patterns) {
|
||||||
StringBuffer stringBuffer = new StringBuffer();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
stringBuffer.append("^");
|
stringBuilder.append("^");
|
||||||
stringBuffer.append(pattern);
|
stringBuilder.append(pattern);
|
||||||
stringBuffer.append("$");
|
stringBuilder.append("$");
|
||||||
result.add(stringBuffer.toString());
|
result.add(stringBuilder.toString());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,11 +109,11 @@ public class AviaterRegexFilter implements CanalEventFilter<String> {
|
|||||||
private List<String> completionPattern(List<String> patterns) {
|
private List<String> completionPattern(List<String> patterns) {
|
||||||
List<String> result = new ArrayList<>();
|
List<String> result = new ArrayList<>();
|
||||||
for (String pattern : patterns) {
|
for (String pattern : patterns) {
|
||||||
StringBuffer stringBuffer = new StringBuffer();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
stringBuffer.append("^");
|
stringBuilder.append("^");
|
||||||
stringBuffer.append(pattern);
|
stringBuilder.append(pattern);
|
||||||
stringBuffer.append("$");
|
stringBuilder.append("$");
|
||||||
result.add(stringBuffer.toString());
|
result.add(stringBuilder.toString());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public class DdlResult {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
DdlResult ddlResult = this;
|
DdlResult ddlResult = this;
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuilder sb = new StringBuilder();
|
||||||
do {
|
do {
|
||||||
sb.append(String.format("DdlResult [schemaName=%s , tableName=%s , oriSchemaName=%s , oriTableName=%s , type=%s ];",
|
sb.append(String.format("DdlResult [schemaName=%s , tableName=%s , oriSchemaName=%s , oriTableName=%s , type=%s ];",
|
||||||
ddlResult.schemaName,
|
ddlResult.schemaName,
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public class MemoryTableMeta implements TableMetaTSDB {
|
|||||||
public Map<String, String> snapshot() {
|
public Map<String, String> snapshot() {
|
||||||
Map<String, String> schemaDdls = new HashMap<>();
|
Map<String, String> schemaDdls = new HashMap<>();
|
||||||
for (Schema schema : repository.getSchemas()) {
|
for (Schema schema : repository.getSchemas()) {
|
||||||
StringBuffer data = new StringBuffer(4 * 1024);
|
StringBuilder data = new StringBuilder(4 * 1024);
|
||||||
for (String table : schema.showTables()) {
|
for (String table : schema.showTables()) {
|
||||||
SchemaObject schemaObject = schema.findTable(table);
|
SchemaObject schemaObject = schema.findTable(table);
|
||||||
schemaObject.getStatement().output(data);
|
schemaObject.getStatement().output(data);
|
||||||
|
|||||||
Reference in New Issue
Block a user