mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
= code cleanup
- for loop replaceable with enhanced 'for' loop - using diamond in generic type - collapse try catch exception - using try-with-resource - using List#sort instead of Collections#sort - replaced lambda with method reference - using native compare method to compare numbers - using switch instead of if for in ESSyncUtil
This commit is contained in:
@@ -22,8 +22,7 @@ public class MysqlBinlogEventPerformanceTest {
|
||||
protected static Charset charset = Charset.forName("utf-8");
|
||||
|
||||
public static void main(String args[]) {
|
||||
DirectLogFetcher fetcher = new DirectLogFetcher();
|
||||
try {
|
||||
try (DirectLogFetcher fetcher = new DirectLogFetcher()) {
|
||||
MysqlConnector connector = new MysqlConnector(new InetSocketAddress("127.0.0.1", 3306), "root", "hello");
|
||||
connector.connect();
|
||||
updateSettings(connector);
|
||||
@@ -49,11 +48,6 @@ public class MysqlBinlogEventPerformanceTest {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
fetcher.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,7 @@ public class MysqlBinlogParsePerformanceTest {
|
||||
protected static Charset charset = Charset.forName("utf-8");
|
||||
|
||||
public static void main(String args[]) {
|
||||
DirectLogFetcher fetcher = new DirectLogFetcher();
|
||||
try {
|
||||
try (DirectLogFetcher fetcher = new DirectLogFetcher()) {
|
||||
MysqlConnector connector = new MysqlConnector(new InetSocketAddress("127.0.0.1", 3306), "root", "hello");
|
||||
connector.connect();
|
||||
updateSettings(connector);
|
||||
@@ -45,9 +44,7 @@ public class MysqlBinlogParsePerformanceTest {
|
||||
Thread thread = new Thread(() -> {
|
||||
try {
|
||||
consumer(buffer);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
@@ -59,11 +56,6 @@ public class MysqlBinlogParsePerformanceTest {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
fetcher.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user