mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
= cold cleanup
* using lambda if possible (we are already building in Java8) * using diamond when new generic instance * remove used improt
This commit is contained in:
@@ -118,13 +118,7 @@ public class CanalInstanceWithManager extends AbstractCanalInstance {
|
||||
} else {
|
||||
try {
|
||||
File externalLibDir = new File(alarmHandlerPluginDir);
|
||||
File[] jarFiles = externalLibDir.listFiles(new FilenameFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.endsWith(".jar");
|
||||
}
|
||||
});
|
||||
File[] jarFiles = externalLibDir.listFiles((dir, name) -> name.endsWith(".jar"));
|
||||
if (jarFiles == null || jarFiles.length == 0) {
|
||||
throw new IllegalStateException(String.format("alarmHandlerPluginDir [%s] can't find any name endswith \".jar\" file.",
|
||||
alarmHandlerPluginDir));
|
||||
@@ -242,9 +236,9 @@ public class CanalInstanceWithManager extends AbstractCanalInstance {
|
||||
List<List<DataSourcing>> groupDbAddresses = parameters.getGroupDbAddresses();
|
||||
if (!CollectionUtils.isEmpty(groupDbAddresses)) {
|
||||
int size = groupDbAddresses.get(0).size();// 取第一个分组的数量,主备分组的数量必须一致
|
||||
List<CanalEventParser> eventParsers = new ArrayList<CanalEventParser>();
|
||||
List<CanalEventParser> eventParsers = new ArrayList<>();
|
||||
for (int i = 0; i < size; i++) {
|
||||
List<InetSocketAddress> dbAddress = new ArrayList<InetSocketAddress>();
|
||||
List<InetSocketAddress> dbAddress = new ArrayList<>();
|
||||
SourcingType lastType = null;
|
||||
for (List<DataSourcing> groupDbAddress : groupDbAddresses) {
|
||||
if (lastType != null && !lastType.equals(groupDbAddress.get(i).getType())) {
|
||||
@@ -270,7 +264,7 @@ public class CanalInstanceWithManager extends AbstractCanalInstance {
|
||||
}
|
||||
} else {
|
||||
// 创建一个空数据库地址的parser,可能使用了tddl指定地址,启动的时候才会从tddl获取地址
|
||||
this.eventParser = doInitEventParser(type, new ArrayList<InetSocketAddress>());
|
||||
this.eventParser = doInitEventParser(type, new ArrayList<>());
|
||||
}
|
||||
|
||||
logger.info("init eventParser end! \n\t load CanalEventParser:{}", eventParser.getClass().getName());
|
||||
@@ -494,7 +488,7 @@ public class CanalInstanceWithManager extends AbstractCanalInstance {
|
||||
|
||||
private synchronized ZkClientx getZkclientx() {
|
||||
// 做一下排序,保证相同的机器只使用同一个链接
|
||||
List<String> zkClusters = new ArrayList<String>(parameters.getZkClusters());
|
||||
List<String> zkClusters = new ArrayList<>(parameters.getZkClusters());
|
||||
Collections.sort(zkClusters);
|
||||
|
||||
return ZkClientx.getZkClient(StringUtils.join(zkClusters, ";"));
|
||||
|
||||
@@ -661,7 +661,7 @@ public class CanalParameter implements Serializable {
|
||||
|
||||
public List<InetSocketAddress> getDbAddresses() {
|
||||
if (dbAddresses == null) {
|
||||
dbAddresses = new ArrayList<InetSocketAddress>();
|
||||
dbAddresses = new ArrayList<>();
|
||||
if (masterAddress != null) {
|
||||
dbAddresses.add(masterAddress);
|
||||
}
|
||||
@@ -675,22 +675,22 @@ public class CanalParameter implements Serializable {
|
||||
|
||||
public List<List<DataSourcing>> getGroupDbAddresses() {
|
||||
if (groupDbAddresses == null) {
|
||||
groupDbAddresses = new ArrayList<List<DataSourcing>>();
|
||||
groupDbAddresses = new ArrayList<>();
|
||||
if (dbAddresses != null) {
|
||||
for (InetSocketAddress address : dbAddresses) {
|
||||
List<DataSourcing> groupAddresses = new ArrayList<DataSourcing>();
|
||||
List<DataSourcing> groupAddresses = new ArrayList<>();
|
||||
groupAddresses.add(new DataSourcing(sourcingType, address));
|
||||
groupDbAddresses.add(groupAddresses);
|
||||
}
|
||||
} else {
|
||||
if (masterAddress != null) {
|
||||
List<DataSourcing> groupAddresses = new ArrayList<DataSourcing>();
|
||||
List<DataSourcing> groupAddresses = new ArrayList<>();
|
||||
groupAddresses.add(new DataSourcing(sourcingType, masterAddress));
|
||||
groupDbAddresses.add(groupAddresses);
|
||||
}
|
||||
|
||||
if (standbyAddress != null) {
|
||||
List<DataSourcing> groupAddresses = new ArrayList<DataSourcing>();
|
||||
List<DataSourcing> groupAddresses = new ArrayList<>();
|
||||
groupAddresses.add(new DataSourcing(sourcingType, standbyAddress));
|
||||
groupDbAddresses.add(groupAddresses);
|
||||
}
|
||||
@@ -731,7 +731,7 @@ public class CanalParameter implements Serializable {
|
||||
|
||||
public List<String> getPositions() {
|
||||
if (positions == null) {
|
||||
positions = new ArrayList<String>();
|
||||
positions = new ArrayList<>();
|
||||
String masterPosition = buildPosition(masterLogfileName, masterLogfileOffest, masterTimestamp);
|
||||
if (masterPosition != null) {
|
||||
positions.add(masterPosition);
|
||||
|
||||
@@ -57,13 +57,7 @@ public class HttpHelper {
|
||||
|
||||
// 创建支持忽略证书的https
|
||||
try {
|
||||
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
|
||||
|
||||
@Override
|
||||
public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
|
||||
return true;
|
||||
}
|
||||
}).build();
|
||||
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, (x509Certificates, s) -> true).build();
|
||||
|
||||
httpclient = HttpClientBuilder.create()
|
||||
.setSSLContext(sslContext)
|
||||
|
||||
@@ -23,14 +23,7 @@ public class PropertyPlaceholderConfigurer extends org.springframework.beans.fac
|
||||
|
||||
private static final String PLACEHOLDER_PREFIX = "${";
|
||||
private static final String PLACEHOLDER_SUFFIX = "}";
|
||||
public static ThreadLocal<Properties> propertiesLocal = new ThreadLocal<Properties>() {
|
||||
|
||||
@Override
|
||||
protected Properties initialValue() {
|
||||
return new Properties();
|
||||
}
|
||||
|
||||
};
|
||||
public static ThreadLocal<Properties> propertiesLocal = ThreadLocal.withInitial(Properties::new);
|
||||
|
||||
private ResourceLoader loader;
|
||||
private String[] locationNames;
|
||||
@@ -57,7 +50,7 @@ public class PropertyPlaceholderConfigurer extends org.springframework.beans.fac
|
||||
}
|
||||
|
||||
if (locationNames != null) {
|
||||
List<Resource> resources = new ArrayList<Resource>(locationNames.length);
|
||||
List<Resource> resources = new ArrayList<>(locationNames.length);
|
||||
|
||||
for (String location : locationNames) {
|
||||
location = trimToNull(location);
|
||||
|
||||
Reference in New Issue
Block a user