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:
@@ -20,7 +20,7 @@ public class Events<EVENT> implements Serializable {
|
||||
private static final long serialVersionUID = -7337454954300706044L;
|
||||
|
||||
private PositionRange positionRange = new PositionRange();
|
||||
private List<EVENT> events = new ArrayList<EVENT>();
|
||||
private List<EVENT> events = new ArrayList<>();
|
||||
|
||||
public List<EVENT> getEvents() {
|
||||
return events;
|
||||
|
||||
@@ -81,9 +81,7 @@ public class MemoryEventStoreMemBatchTest extends MemoryEventStoreBase {
|
||||
|
||||
try {
|
||||
result = eventStore.put(buildEvent("1", 1L, 1L + bufferSize), 1000L, TimeUnit.MILLISECONDS);
|
||||
} catch (CanalStoreException e) {
|
||||
Assert.fail(e.getMessage());
|
||||
} catch (InterruptedException e) {
|
||||
} catch (CanalStoreException | InterruptedException e) {
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
|
||||
@@ -162,8 +160,7 @@ public class MemoryEventStoreMemBatchTest extends MemoryEventStoreBase {
|
||||
Assert.assertTrue(entrys.getEvents().size() == batchSize);
|
||||
Assert.assertEquals(position, entrys.getPositionRange().getStart());
|
||||
Assert.assertEquals(position, entrys.getPositionRange().getEnd());
|
||||
} catch (CanalStoreException e) {
|
||||
} catch (InterruptedException e) {
|
||||
} catch (CanalStoreException | InterruptedException e) {
|
||||
}
|
||||
|
||||
ExecutorService executor = Executors.newFixedThreadPool(1);
|
||||
|
||||
@@ -109,8 +109,7 @@ public class MemoryEventStoreMultiThreadTest extends MemoryEventStoreBase {
|
||||
}
|
||||
try {
|
||||
eventStore.put(event);
|
||||
} catch (CanalStoreException e) {
|
||||
} catch (InterruptedException e) {
|
||||
} catch (CanalStoreException | InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,9 +64,7 @@ public class MemoryEventStorePutAndGetTest extends MemoryEventStoreBase {
|
||||
|
||||
try {
|
||||
result = eventStore.put(buildEvent("1", 1L, 1L + bufferSize), 1000L, TimeUnit.MILLISECONDS);
|
||||
} catch (CanalStoreException e) {
|
||||
Assert.fail(e.getMessage());
|
||||
} catch (InterruptedException e) {
|
||||
} catch (CanalStoreException | InterruptedException e) {
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
|
||||
@@ -140,8 +138,7 @@ public class MemoryEventStorePutAndGetTest extends MemoryEventStoreBase {
|
||||
Assert.assertTrue(entrys.getEvents().size() == batchSize);
|
||||
Assert.assertEquals(position, entrys.getPositionRange().getStart());
|
||||
Assert.assertEquals(position, entrys.getPositionRange().getEnd());
|
||||
} catch (CanalStoreException e) {
|
||||
} catch (InterruptedException e) {
|
||||
} catch (CanalStoreException | InterruptedException e) {
|
||||
}
|
||||
|
||||
ExecutorService executor = Executors.newFixedThreadPool(1);
|
||||
|
||||
Reference in New Issue
Block a user