mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Lambdas.
This commit is contained in:
@@ -23,12 +23,8 @@ public class MessageTreeImpl<T extends MessageTree.MessageNode>
|
||||
private final List<T> roots = new ArrayList<>();
|
||||
private final List<List<T>> unsortedLists = new ArrayList<>();
|
||||
|
||||
private Comparator<T> comparator = new Comparator<T>() {
|
||||
@Override
|
||||
public int compare(T o1, T o2) {
|
||||
return Long.valueOf(o1.getTimestamp()).compareTo(o2.getTimestamp());
|
||||
}
|
||||
};
|
||||
private Comparator<T> comparator = (o1, o2) ->
|
||||
Long.valueOf(o1.getTimestamp()).compareTo(o2.getTimestamp());
|
||||
|
||||
@Override
|
||||
public synchronized void clear() {
|
||||
|
||||
@@ -129,17 +129,7 @@ class FeedManagerImpl implements FeedManager, Client, EventListener,
|
||||
private void startFeedExecutor() {
|
||||
if (fetcherStarted.getAndSet(true)) return;
|
||||
LOG.info("Tor started, scheduling RSS feed fetcher");
|
||||
Runnable fetcher = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ioExecutor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fetchFeeds();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
Runnable fetcher = () -> ioExecutor.execute(this::fetchFeeds);
|
||||
scheduler.scheduleWithFixedDelay(fetcher, FETCH_DELAY_INITIAL,
|
||||
FETCH_INTERVAL, FETCH_UNIT);
|
||||
}
|
||||
@@ -502,23 +492,18 @@ class FeedManagerImpl implements FeedManager, Client, EventListener,
|
||||
}
|
||||
|
||||
private Comparator<SyndEntry> getEntryComparator() {
|
||||
return new Comparator<SyndEntry>() {
|
||||
@Override
|
||||
public int compare(SyndEntry e1, SyndEntry e2) {
|
||||
Date d1 =
|
||||
e1.getPublishedDate() != null ? e1.getPublishedDate() :
|
||||
e1.getUpdatedDate();
|
||||
Date d2 =
|
||||
e2.getPublishedDate() != null ? e2.getPublishedDate() :
|
||||
e2.getUpdatedDate();
|
||||
if (d1 == null && d2 == null) return 0;
|
||||
if (d1 == null) return -1;
|
||||
if (d2 == null) return 1;
|
||||
return (e1, e2) -> {
|
||||
Date d1 = e1.getPublishedDate() != null ? e1.getPublishedDate() :
|
||||
e1.getUpdatedDate();
|
||||
Date d2 = e2.getPublishedDate() != null ? e2.getPublishedDate() :
|
||||
e2.getUpdatedDate();
|
||||
if (d1 == null && d2 == null) return 0;
|
||||
if (d1 == null) return -1;
|
||||
if (d2 == null) return 1;
|
||||
|
||||
if (d1.after(d2)) return 1;
|
||||
if (d1.before(d2)) return -1;
|
||||
return 0;
|
||||
}
|
||||
if (d1.after(d2)) return 1;
|
||||
if (d1.before(d2)) return -1;
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -118,16 +118,12 @@ public class TestDataCreatorImpl implements TestDataCreator {
|
||||
}
|
||||
|
||||
public void createTestData() {
|
||||
ioExecutor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
createTestDataOnDbExecutor();
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING)) {
|
||||
LOG.log(WARNING, "Creating test data failed", e);
|
||||
}
|
||||
}
|
||||
ioExecutor.execute(() -> {
|
||||
try {
|
||||
createTestDataOnDbExecutor();
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING))
|
||||
LOG.log(WARNING, "Creating test data failed", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -706,39 +706,29 @@ public class IntroductionIntegrationTest
|
||||
|
||||
@Test
|
||||
public void testModifiedTransportProperties() throws Exception {
|
||||
testModifiedResponse(new StateVisitor() {
|
||||
@Override
|
||||
public boolean visit(BdfDictionary response) {
|
||||
BdfDictionary tp = response.getDictionary(TRANSPORT, null);
|
||||
tp.put("fakeId",
|
||||
BdfDictionary.of(new BdfEntry("fake", "fake")));
|
||||
response.put(TRANSPORT, tp);
|
||||
return false;
|
||||
}
|
||||
testModifiedResponse(response -> {
|
||||
BdfDictionary tp = response.getDictionary(TRANSPORT, null);
|
||||
tp.put("fakeId", BdfDictionary.of(new BdfEntry("fake", "fake")));
|
||||
response.put(TRANSPORT, tp);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifiedTimestamp() throws Exception {
|
||||
testModifiedResponse(new StateVisitor() {
|
||||
@Override
|
||||
public boolean visit(BdfDictionary response) {
|
||||
long timestamp = response.getLong(TIME, 0L);
|
||||
response.put(TIME, timestamp + 1);
|
||||
return false;
|
||||
}
|
||||
testModifiedResponse(response -> {
|
||||
long timestamp = response.getLong(TIME, 0L);
|
||||
response.put(TIME, timestamp + 1);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifiedEphemeralPublicKey() throws Exception {
|
||||
testModifiedResponse(new StateVisitor() {
|
||||
@Override
|
||||
public boolean visit(BdfDictionary response) {
|
||||
KeyPair keyPair = crypto.generateSignatureKeyPair();
|
||||
response.put(E_PUBLIC_KEY, keyPair.getPublic().getEncoded());
|
||||
return true;
|
||||
}
|
||||
testModifiedResponse(response -> {
|
||||
KeyPair keyPair = crypto.generateSignatureKeyPair();
|
||||
response.put(E_PUBLIC_KEY, keyPair.getPublic().getEncoded());
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user