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:
@@ -64,7 +64,7 @@ public class MysqlQueryExecutor {
|
||||
ResultSetHeaderPacket rsHeader = new ResultSetHeaderPacket();
|
||||
rsHeader.fromBytes(body);
|
||||
|
||||
List<FieldPacket> fields = new ArrayList<FieldPacket>();
|
||||
List<FieldPacket> fields = new ArrayList<>();
|
||||
for (int i = 0; i < rsHeader.getColumnCount(); i++) {
|
||||
FieldPacket fp = new FieldPacket();
|
||||
fp.fromBytes(readNextPacket());
|
||||
@@ -73,7 +73,7 @@ public class MysqlQueryExecutor {
|
||||
|
||||
readEofPacket();
|
||||
|
||||
List<RowDataPacket> rowData = new ArrayList<RowDataPacket>();
|
||||
List<RowDataPacket> rowData = new ArrayList<>();
|
||||
while (true) {
|
||||
body = readNextPacket();
|
||||
if (body[0] == -2) {
|
||||
@@ -99,7 +99,7 @@ public class MysqlQueryExecutor {
|
||||
cmd.setQueryString(queryString);
|
||||
byte[] bodyBytes = cmd.toBytes();
|
||||
PacketManager.writeBody(channel, bodyBytes);
|
||||
List<ResultSetPacket> resultSets = new ArrayList<ResultSetPacket>();
|
||||
List<ResultSetPacket> resultSets = new ArrayList<>();
|
||||
boolean moreResult = true;
|
||||
while (moreResult) {
|
||||
byte[] body = readNextPacket();
|
||||
@@ -112,7 +112,7 @@ public class MysqlQueryExecutor {
|
||||
ResultSetHeaderPacket rsHeader = new ResultSetHeaderPacket();
|
||||
rsHeader.fromBytes(body);
|
||||
|
||||
List<FieldPacket> fields = new ArrayList<FieldPacket>();
|
||||
List<FieldPacket> fields = new ArrayList<>();
|
||||
for (int i = 0; i < rsHeader.getColumnCount(); i++) {
|
||||
FieldPacket fp = new FieldPacket();
|
||||
fp.fromBytes(readNextPacket());
|
||||
@@ -121,7 +121,7 @@ public class MysqlQueryExecutor {
|
||||
|
||||
moreResult = readEofPacket();
|
||||
|
||||
List<RowDataPacket> rowData = new ArrayList<RowDataPacket>();
|
||||
List<RowDataPacket> rowData = new ArrayList<>();
|
||||
while (true) {
|
||||
body = readNextPacket();
|
||||
if (body[0] == -2) {
|
||||
|
||||
@@ -84,11 +84,11 @@ public class MysqlGTIDSet implements GTIDSet {
|
||||
Map<String, UUIDSet> m;
|
||||
|
||||
if (gtidData == null || gtidData.length() < 1) {
|
||||
m = new HashMap<String, UUIDSet>();
|
||||
m = new HashMap<>();
|
||||
} else {
|
||||
// 存在多个GTID时会有回车符
|
||||
String[] uuidStrs = gtidData.replaceAll("\n", "").split(",");
|
||||
m = new HashMap<String, UUIDSet>(uuidStrs.length);
|
||||
m = new HashMap<>(uuidStrs.length);
|
||||
for (int i = 0; i < uuidStrs.length; i++) {
|
||||
UUIDSet uuidSet = UUIDSet.parse(uuidStrs[i]);
|
||||
m.put(uuidSet.SID.toString(), uuidSet);
|
||||
|
||||
@@ -105,7 +105,7 @@ public class UUIDSet {
|
||||
throw new RuntimeException(String.format("parseUUIDSet failed due to wrong format: %s", str));
|
||||
}
|
||||
|
||||
List<Interval> intervals = new ArrayList<Interval>();
|
||||
List<Interval> intervals = new ArrayList<>();
|
||||
for (int i = 1; i < ss.length; i++) {
|
||||
intervals.add(parseInterval(ss[i]));
|
||||
}
|
||||
@@ -172,7 +172,7 @@ public class UUIDSet {
|
||||
* @return
|
||||
*/
|
||||
public static List<Interval> combine(List<Interval> intervals) {
|
||||
List<Interval> combined = new ArrayList<Interval>();
|
||||
List<Interval> combined = new ArrayList<>();
|
||||
Collections.sort(intervals);
|
||||
int len = intervals.size();
|
||||
for (int i = 0; i < len; i++) {
|
||||
|
||||
@@ -7,8 +7,8 @@ import java.util.List;
|
||||
public class ResultSetPacket {
|
||||
|
||||
private SocketAddress sourceAddress;
|
||||
private List<FieldPacket> fieldDescriptors = new ArrayList<FieldPacket>();
|
||||
private List<String> fieldValues = new ArrayList<String>();
|
||||
private List<FieldPacket> fieldDescriptors = new ArrayList<>();
|
||||
private List<String> fieldValues = new ArrayList<>();
|
||||
|
||||
public void setFieldDescriptors(List<FieldPacket> fieldDescriptors) {
|
||||
this.fieldDescriptors = fieldDescriptors;
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.alibaba.otter.canal.parse.driver.mysql.utils.LengthCodedStringReader;
|
||||
|
||||
public class RowDataPacket extends PacketWithHeaderPacket {
|
||||
|
||||
private List<String> columns = new ArrayList<String>();
|
||||
private List<String> columns = new ArrayList<>();
|
||||
|
||||
public void fromBytes(byte[] data) throws IOException {
|
||||
int index = 0;
|
||||
|
||||
@@ -31,7 +31,7 @@ public abstract class NettySocketChannelPool {
|
||||
|
||||
private static EventLoopGroup group = new NioEventLoopGroup(); // 非阻塞IO线程组
|
||||
private static Bootstrap boot = new Bootstrap(); // 主
|
||||
private static Map<Channel, SocketChannel> chManager = new ConcurrentHashMap<Channel, SocketChannel>();
|
||||
private static Map<Channel, SocketChannel> chManager = new ConcurrentHashMap<>();
|
||||
private static final Logger logger = LoggerFactory.getLogger(NettySocketChannelPool.class);
|
||||
|
||||
static {
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.apache.commons.lang.StringUtils;
|
||||
public class CharsetUtil {
|
||||
|
||||
private static final String[] INDEX_TO_CHARSET = new String[2048];
|
||||
private static final Map<String, Integer> CHARSET_TO_INDEX = new HashMap<String, Integer>();
|
||||
private static final Map<String, Integer> CHARSET_TO_INDEX = new HashMap<>();
|
||||
static {
|
||||
INDEX_TO_CHARSET[1] = "big5";
|
||||
INDEX_TO_CHARSET[84] = "big5";
|
||||
|
||||
@@ -38,7 +38,7 @@ public class MysqlGTIDSetTest {
|
||||
|
||||
@Test
|
||||
public void testParse() {
|
||||
Map<String, MysqlGTIDSet> cases = new HashMap<String, MysqlGTIDSet>(5);
|
||||
Map<String, MysqlGTIDSet> cases = new HashMap<>(5);
|
||||
cases.put("726757ad-4455-11e8-ae04-0242ac110002:1",
|
||||
buildForTest(new Material("726757ad-4455-11e8-ae04-0242ac110002", 1, 2)));
|
||||
cases.put("726757ad-4455-11e8-ae04-0242ac110002:1-3",
|
||||
@@ -89,12 +89,12 @@ public class MysqlGTIDSetTest {
|
||||
}
|
||||
|
||||
private MysqlGTIDSet buildForTest(List<Material> materials) {
|
||||
Map<String, UUIDSet> sets = new HashMap<String, UUIDSet>();
|
||||
Map<String, UUIDSet> sets = new HashMap<>();
|
||||
for (Material a : materials) {
|
||||
UUIDSet.Interval interval = new UUIDSet.Interval();
|
||||
interval.start = a.start;
|
||||
interval.stop = a.stop;
|
||||
List<UUIDSet.Interval> intervals = new ArrayList<UUIDSet.Interval>();
|
||||
List<UUIDSet.Interval> intervals = new ArrayList<>();
|
||||
intervals.add(interval);
|
||||
|
||||
if (a.start1 > 0 && a.stop1 > 0) {
|
||||
|
||||
@@ -16,7 +16,7 @@ public class UUIDSetTest {
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
Map<String, String> cases = new HashMap<String, String>(4);
|
||||
Map<String, String> cases = new HashMap<>(4);
|
||||
cases.put("726757ad-4455-11e8-ae04-0242ac110002:1", "726757ad-4455-11e8-ae04-0242ac110002:1");
|
||||
cases.put("726757ad-4455-11e8-ae04-0242ac110002:1-3", "726757ad-4455-11e8-ae04-0242ac110002:1-3");
|
||||
cases.put("726757ad-4455-11e8-ae04-0242ac110002:1-3:4-6", "726757ad-4455-11e8-ae04-0242ac110002:1-6");
|
||||
|
||||
Reference in New Issue
Block a user