mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Reformat code.
This commit is contained in:
@@ -144,8 +144,8 @@ class ClientHelperImpl implements ClientHelper {
|
||||
@Override
|
||||
public BdfDictionary getMessageMetadataAsDictionary(MessageId m)
|
||||
throws DbException, FormatException {
|
||||
return db.transactionWithResult(true,
|
||||
txn -> getMessageMetadataAsDictionary(txn, m));
|
||||
return db.transactionWithResult(true, txn ->
|
||||
getMessageMetadataAsDictionary(txn, m));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -158,8 +158,8 @@ class ClientHelperImpl implements ClientHelper {
|
||||
@Override
|
||||
public Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
|
||||
GroupId g) throws DbException, FormatException {
|
||||
return db.transactionWithResult(true,
|
||||
txn -> getMessageMetadataAsDictionary(txn, g));
|
||||
return db.transactionWithResult(true, txn ->
|
||||
getMessageMetadataAsDictionary(txn, g));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -176,8 +176,8 @@ class ClientHelperImpl implements ClientHelper {
|
||||
public Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
|
||||
GroupId g, BdfDictionary query) throws DbException,
|
||||
FormatException {
|
||||
return db.transactionWithResult(true,
|
||||
txn -> getMessageMetadataAsDictionary(txn, g, query));
|
||||
return db.transactionWithResult(true, txn ->
|
||||
getMessageMetadataAsDictionary(txn, g, query));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -79,8 +79,8 @@ class ContactManagerImpl implements ContactManager {
|
||||
public ContactId addContact(Author remote, AuthorId local, SecretKey master,
|
||||
long timestamp, boolean alice, boolean verified, boolean active)
|
||||
throws DbException {
|
||||
return db.transactionWithResult(false,
|
||||
txn -> addContact(txn, remote, local, master, timestamp, alice,
|
||||
return db.transactionWithResult(false, txn ->
|
||||
addContact(txn, remote, local, master, timestamp, alice,
|
||||
verified, active));
|
||||
}
|
||||
|
||||
@@ -92,8 +92,8 @@ class ContactManagerImpl implements ContactManager {
|
||||
@Override
|
||||
public Contact getContact(AuthorId remoteAuthorId, AuthorId localAuthorId)
|
||||
throws DbException {
|
||||
return db.transactionWithResult(true,
|
||||
txn -> getContact(txn, remoteAuthorId, localAuthorId));
|
||||
return db.transactionWithResult(true, txn ->
|
||||
getContact(txn, remoteAuthorId, localAuthorId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -155,8 +155,8 @@ class ContactManagerImpl implements ContactManager {
|
||||
@Override
|
||||
public boolean contactExists(AuthorId remoteAuthorId,
|
||||
AuthorId localAuthorId) throws DbException {
|
||||
return db.transactionWithResult(true,
|
||||
txn -> contactExists(txn, remoteAuthorId, localAuthorId));
|
||||
return db.transactionWithResult(true, txn ->
|
||||
contactExists(txn, remoteAuthorId, localAuthorId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -218,8 +218,8 @@ class TransportPropertyManagerImpl implements TransportPropertyManager,
|
||||
@Override
|
||||
public TransportProperties getRemoteProperties(ContactId c, TransportId t)
|
||||
throws DbException {
|
||||
return db.transactionWithResult(true,
|
||||
txn -> getRemoteProperties(txn, db.getContact(txn, c), t));
|
||||
return db.transactionWithResult(true, txn ->
|
||||
getRemoteProperties(txn, db.getContact(txn, c), t));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,8 +23,8 @@ class SettingsManagerImpl implements SettingsManager {
|
||||
|
||||
@Override
|
||||
public Settings getSettings(String namespace) throws DbException {
|
||||
return db.transactionWithResult(true,
|
||||
txn -> db.getSettings(txn, namespace));
|
||||
return db.transactionWithResult(true, txn ->
|
||||
db.getSettings(txn, namespace));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -230,8 +230,8 @@ class DuplexOutgoingSession implements SyncSession, EventListener {
|
||||
if (interrupted) return;
|
||||
if (!generateAckQueued.getAndSet(false)) throw new AssertionError();
|
||||
try {
|
||||
Maybe<Ack> a = db.transactionWithResult(false,
|
||||
txn -> new Maybe<>(db.generateAck(txn, contactId,
|
||||
Maybe<Ack> a = db.transactionWithResult(false, txn ->
|
||||
new Maybe<>(db.generateAck(txn, contactId,
|
||||
MAX_MESSAGE_IDS)));
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Generated ack: " + a.isPresent());
|
||||
@@ -357,8 +357,8 @@ class DuplexOutgoingSession implements SyncSession, EventListener {
|
||||
if (!generateRequestQueued.getAndSet(false))
|
||||
throw new AssertionError();
|
||||
try {
|
||||
Maybe<Request> r = db.transactionWithResult(false,
|
||||
txn -> new Maybe<>(db.generateRequest(txn, contactId,
|
||||
Maybe<Request> r = db.transactionWithResult(false, txn ->
|
||||
new Maybe<>(db.generateRequest(txn, contactId,
|
||||
MAX_MESSAGE_IDS)));
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Generated request: " + r.isPresent());
|
||||
|
||||
@@ -119,8 +119,8 @@ class IncomingSession implements SyncSession, EventListener {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
db.transaction(false,
|
||||
txn -> db.receiveAck(txn, contactId, ack));
|
||||
db.transaction(false, txn ->
|
||||
db.receiveAck(txn, contactId, ack));
|
||||
} catch (DbException e) {
|
||||
logException(LOG, WARNING, e);
|
||||
interrupt();
|
||||
@@ -140,8 +140,8 @@ class IncomingSession implements SyncSession, EventListener {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
db.transaction(false,
|
||||
txn -> db.receiveMessage(txn, contactId, message));
|
||||
db.transaction(false, txn ->
|
||||
db.receiveMessage(txn, contactId, message));
|
||||
} catch (DbException e) {
|
||||
logException(LOG, WARNING, e);
|
||||
interrupt();
|
||||
@@ -161,8 +161,8 @@ class IncomingSession implements SyncSession, EventListener {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
db.transaction(false,
|
||||
txn -> db.receiveOffer(txn, contactId, offer));
|
||||
db.transaction(false, txn ->
|
||||
db.receiveOffer(txn, contactId, offer));
|
||||
} catch (DbException e) {
|
||||
logException(LOG, WARNING, e);
|
||||
interrupt();
|
||||
@@ -182,8 +182,8 @@ class IncomingSession implements SyncSession, EventListener {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
db.transaction(false,
|
||||
txn -> db.receiveRequest(txn, contactId, request));
|
||||
db.transaction(false, txn ->
|
||||
db.receiveRequest(txn, contactId, request));
|
||||
} catch (DbException e) {
|
||||
logException(LOG, WARNING, e);
|
||||
interrupt();
|
||||
|
||||
@@ -129,8 +129,8 @@ class SimplexOutgoingSession implements SyncSession, EventListener {
|
||||
public void run() {
|
||||
if (interrupted) return;
|
||||
try {
|
||||
Maybe<Ack> a = db.transactionWithResult(false,
|
||||
txn -> new Maybe<>(db.generateAck(txn, contactId,
|
||||
Maybe<Ack> a = db.transactionWithResult(false, txn ->
|
||||
new Maybe<>(db.generateAck(txn, contactId,
|
||||
MAX_MESSAGE_IDS)));
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Generated ack: " + a.isPresent());
|
||||
|
||||
@@ -434,8 +434,8 @@ class ValidationManagerImpl implements ValidationManager, Service,
|
||||
@DatabaseExecutor
|
||||
private void loadGroupAndValidate(Message m) {
|
||||
try {
|
||||
Group g = db.transactionWithResult(true,
|
||||
txn -> db.getGroup(txn, m.getGroupId()));
|
||||
Group g = db.transactionWithResult(true, txn ->
|
||||
db.getGroup(txn, m.getGroupId()));
|
||||
validateMessageAsync(m, g);
|
||||
} catch (NoSuchGroupException e) {
|
||||
LOG.info("Group removed before validation");
|
||||
|
||||
@@ -137,8 +137,8 @@ class KeyManagerImpl implements KeyManager, Service, EventListener {
|
||||
if (LOG.isLoggable(INFO)) LOG.info("No key manager for " + t);
|
||||
return null;
|
||||
}
|
||||
return db.transactionWithResult(false,
|
||||
txn -> m.getStreamContext(txn, c));
|
||||
return db.transactionWithResult(false, txn ->
|
||||
m.getStreamContext(txn, c));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -149,8 +149,8 @@ class KeyManagerImpl implements KeyManager, Service, EventListener {
|
||||
if (LOG.isLoggable(INFO)) LOG.info("No key manager for " + t);
|
||||
return null;
|
||||
}
|
||||
return db.transactionWithResult(false,
|
||||
txn -> m.getStreamContext(txn, tag));
|
||||
return db.transactionWithResult(false, txn ->
|
||||
m.getStreamContext(txn, tag));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -303,17 +303,17 @@ public class IntroductionIntegrationTest
|
||||
.getMessageHeaders(txn, contactId1From0));
|
||||
assertEquals(2, messages.size());
|
||||
assertGroupCount(messageTracker0, g1.getId(), 2, 1);
|
||||
messages = db0.transactionWithResult(true,
|
||||
txn -> introductionManager0.getMessageHeaders(txn, contactId2From0));
|
||||
messages = db0.transactionWithResult(true, txn ->
|
||||
introductionManager0.getMessageHeaders(txn, contactId2From0));
|
||||
assertEquals(2, messages.size());
|
||||
assertGroupCount(messageTracker0, g2.getId(), 2, 1);
|
||||
messages = db1.transactionWithResult(true,
|
||||
txn -> introductionManager1.getMessageHeaders(txn, contactId0From1));
|
||||
messages = db1.transactionWithResult(true, txn ->
|
||||
introductionManager1.getMessageHeaders(txn, contactId0From1));
|
||||
assertEquals(2, messages.size());
|
||||
assertGroupCount(messageTracker1, g1.getId(), 2, 1);
|
||||
// introducee2 should also have the decline response of introducee1
|
||||
messages = db2.transactionWithResult(true,
|
||||
txn -> introductionManager2.getMessageHeaders(txn, contactId0From2));
|
||||
messages = db2.transactionWithResult(true, txn ->
|
||||
introductionManager2.getMessageHeaders(txn, contactId0From2));
|
||||
assertEquals(3, messages.size());
|
||||
assertGroupCount(messageTracker2, g2.getId(), 3, 2);
|
||||
|
||||
@@ -368,17 +368,14 @@ public class IntroductionIntegrationTest
|
||||
db0.transactionWithResult(true, txn -> introductionManager0
|
||||
.getMessageHeaders(txn, contactId1From0));
|
||||
assertEquals(2, messages.size());
|
||||
messages = db0.transactionWithResult(true,
|
||||
txn -> introductionManager0
|
||||
.getMessageHeaders(txn, contactId2From0));
|
||||
messages = db0.transactionWithResult(true, txn ->
|
||||
introductionManager0.getMessageHeaders(txn, contactId2From0));
|
||||
assertEquals(2, messages.size());
|
||||
messages = db1.transactionWithResult(true,
|
||||
txn -> introductionManager1
|
||||
.getMessageHeaders(txn, contactId0From1));
|
||||
messages = db1.transactionWithResult(true, txn ->
|
||||
introductionManager1.getMessageHeaders(txn, contactId0From1));
|
||||
assertEquals(3, messages.size());
|
||||
messages = db2.transactionWithResult(true,
|
||||
txn -> introductionManager2
|
||||
.getMessageHeaders(txn, contactId0From2));
|
||||
messages = db2.transactionWithResult(true, txn ->
|
||||
introductionManager2.getMessageHeaders(txn, contactId0From2));
|
||||
assertEquals(3, messages.size());
|
||||
assertFalse(listener0.aborted);
|
||||
assertFalse(listener1.aborted);
|
||||
@@ -525,20 +522,20 @@ public class IntroductionIntegrationTest
|
||||
|
||||
Group g1 = introductionManager0.getContactGroup(introducee1);
|
||||
Group g2 = introductionManager0.getContactGroup(introducee2);
|
||||
assertEquals(2, db0.transactionWithResult(true,
|
||||
txn -> introductionManager0.getMessageHeaders(txn, contactId1From0))
|
||||
assertEquals(2, db0.transactionWithResult(true, txn ->
|
||||
introductionManager0.getMessageHeaders(txn, contactId1From0))
|
||||
.size());
|
||||
assertGroupCount(messageTracker0, g1.getId(), 2, 1);
|
||||
assertEquals(2, db0.transactionWithResult(true,
|
||||
txn -> introductionManager0.getMessageHeaders(txn, contactId2From0))
|
||||
assertEquals(2, db0.transactionWithResult(true, txn ->
|
||||
introductionManager0.getMessageHeaders(txn, contactId2From0))
|
||||
.size());
|
||||
assertGroupCount(messageTracker0, g2.getId(), 2, 1);
|
||||
assertEquals(3, db1.transactionWithResult(true,
|
||||
txn -> introductionManager1.getMessageHeaders(txn, contactId0From1))
|
||||
assertEquals(3, db1.transactionWithResult(true, txn ->
|
||||
introductionManager1.getMessageHeaders(txn, contactId0From1))
|
||||
.size());
|
||||
assertGroupCount(messageTracker1, g1.getId(), 3, 2);
|
||||
assertEquals(3, db2.transactionWithResult(true,
|
||||
txn -> introductionManager2.getMessageHeaders(txn, contactId0From2))
|
||||
assertEquals(3, db2.transactionWithResult(true, txn ->
|
||||
introductionManager2.getMessageHeaders(txn, contactId0From2))
|
||||
.size());
|
||||
assertGroupCount(messageTracker2, g2.getId(), 3, 2);
|
||||
|
||||
@@ -563,8 +560,8 @@ public class IntroductionIntegrationTest
|
||||
assertFalse(listener1.requestReceived);
|
||||
|
||||
// make really sure we don't have that request
|
||||
assertTrue(db1.transactionWithResult(true,
|
||||
txn -> introductionManager1.getMessageHeaders(txn, contactId0From1))
|
||||
assertTrue(db1.transactionWithResult(true, txn ->
|
||||
introductionManager1.getMessageHeaders(txn, contactId0From1))
|
||||
.isEmpty());
|
||||
|
||||
// The message was invalid, so no abort message was sent
|
||||
@@ -1104,23 +1101,23 @@ public class IntroductionIntegrationTest
|
||||
|
||||
private void assertDefaultUiMessages() throws DbException {
|
||||
Collection<ConversationMessageHeader> messages =
|
||||
db0.transactionWithResult(true, txn -> introductionManager0
|
||||
.getMessageHeaders(txn, contactId1From0));
|
||||
db0.transactionWithResult(true, txn ->
|
||||
introductionManager0.getMessageHeaders(txn, contactId1From0));
|
||||
assertEquals(2, messages.size());
|
||||
assertMessagesAreAcked(messages);
|
||||
|
||||
messages = db0.transactionWithResult(true, txn -> introductionManager0
|
||||
.getMessageHeaders(txn, contactId2From0));
|
||||
messages = db0.transactionWithResult(true, txn ->
|
||||
introductionManager0.getMessageHeaders(txn, contactId2From0));
|
||||
assertEquals(2, messages.size());
|
||||
assertMessagesAreAcked(messages);
|
||||
|
||||
messages = db1.transactionWithResult(true, txn -> introductionManager1
|
||||
.getMessageHeaders(txn, contactId0From1));
|
||||
messages = db1.transactionWithResult(true, txn ->
|
||||
introductionManager1.getMessageHeaders(txn, contactId0From1));
|
||||
assertEquals(2, messages.size());
|
||||
assertMessagesAreAcked(messages);
|
||||
|
||||
messages = db2.transactionWithResult(true, txn -> introductionManager2
|
||||
.getMessageHeaders(txn, contactId0From2));
|
||||
messages = db2.transactionWithResult(true, txn ->
|
||||
introductionManager2.getMessageHeaders(txn, contactId0From2));
|
||||
assertEquals(2, messages.size());
|
||||
assertMessagesAreAcked(messages);
|
||||
}
|
||||
@@ -1303,8 +1300,9 @@ public class IntroductionIntegrationTest
|
||||
private IntroductionRequest getIntroductionRequest(DatabaseComponent db,
|
||||
IntroductionManager manager, ContactId contactId)
|
||||
throws DbException {
|
||||
Collection<ConversationMessageHeader> messages = db.transactionWithResult(
|
||||
true, txn -> manager.getMessageHeaders(txn, contactId));
|
||||
Collection<ConversationMessageHeader> messages =
|
||||
db.transactionWithResult(true, txn ->
|
||||
manager.getMessageHeaders(txn, contactId));
|
||||
for (ConversationMessageHeader im : messages) {
|
||||
if (im instanceof IntroductionRequest) {
|
||||
return (IntroductionRequest) im;
|
||||
|
||||
@@ -497,8 +497,8 @@ public class PrivateGroupManagerIntegrationTest
|
||||
assertFalse(groupManager1.isDissolved(groupId0));
|
||||
|
||||
// creator dissolves group
|
||||
db1.transaction(false,
|
||||
txn -> groupManager1.markGroupDissolved(txn, groupId0));
|
||||
db1.transaction(false, txn ->
|
||||
groupManager1.markGroupDissolved(txn, groupId0));
|
||||
|
||||
// group is dissolved now
|
||||
assertTrue(groupManager1.isDissolved(groupId0));
|
||||
|
||||
@@ -137,8 +137,9 @@ public class GroupInvitationIntegrationTest
|
||||
|
||||
sync1To0(1, true);
|
||||
|
||||
messages = db0.transactionWithResult(true, txn -> groupInvitationManager0
|
||||
.getMessageHeaders(txn, contactId1From0));
|
||||
messages = db0.transactionWithResult(true, txn ->
|
||||
groupInvitationManager0
|
||||
.getMessageHeaders(txn, contactId1From0));
|
||||
assertEquals(2, messages.size());
|
||||
foundResponse = false;
|
||||
for (ConversationMessageHeader m : messages) {
|
||||
@@ -191,8 +192,9 @@ public class GroupInvitationIntegrationTest
|
||||
|
||||
sync1To0(1, true);
|
||||
|
||||
messages = db1.transactionWithResult(true, txn -> groupInvitationManager0
|
||||
.getMessageHeaders(txn, contactId1From0));
|
||||
messages = db1.transactionWithResult(true, txn ->
|
||||
groupInvitationManager0
|
||||
.getMessageHeaders(txn, contactId1From0));
|
||||
assertEquals(2, messages.size());
|
||||
foundResponse = false;
|
||||
for (ConversationMessageHeader m : messages) {
|
||||
@@ -227,10 +229,9 @@ public class GroupInvitationIntegrationTest
|
||||
// 1 has one unread message
|
||||
Group g0 = groupInvitationManager1.getContactGroup(contact0From1);
|
||||
assertGroupCount(messageTracker1, g0.getId(), 1, 1, timestamp);
|
||||
ConversationMessageHeader m = db1.transactionWithResult(true,
|
||||
txn -> groupInvitationManager1
|
||||
.getMessageHeaders(txn, contactId0From1).iterator()
|
||||
.next());
|
||||
ConversationMessageHeader m = db1.transactionWithResult(true, txn ->
|
||||
groupInvitationManager1.getMessageHeaders(txn, contactId0From1)
|
||||
.iterator().next());
|
||||
|
||||
groupInvitationManager1
|
||||
.respondToInvitation(contactId0From1, privateGroup0, true);
|
||||
|
||||
@@ -242,8 +242,8 @@ public class BlogSharingIntegrationTest
|
||||
}
|
||||
}
|
||||
// sharer has own invitation message and response
|
||||
assertEquals(2, db0.transactionWithResult(true,
|
||||
txn -> blogSharingManager0.getMessageHeaders(txn, contactId1From0))
|
||||
assertEquals(2, db0.transactionWithResult(true, txn ->
|
||||
blogSharingManager0.getMessageHeaders(txn, contactId1From0))
|
||||
.size());
|
||||
// blog can not be shared again
|
||||
assertFalse(blogSharingManager0.canBeShared(rssBlog.getId(),
|
||||
@@ -304,8 +304,8 @@ public class BlogSharingIntegrationTest
|
||||
}
|
||||
}
|
||||
// sharer has own invitation message and response
|
||||
assertEquals(2, db0.transactionWithResult(true,
|
||||
txn -> blogSharingManager0.getMessageHeaders(txn, contactId1From0))
|
||||
assertEquals(2, db0.transactionWithResult(true, txn ->
|
||||
blogSharingManager0.getMessageHeaders(txn, contactId1From0))
|
||||
.size());
|
||||
// blog can be shared again
|
||||
assertTrue(
|
||||
|
||||
@@ -152,7 +152,8 @@ public class ForumSharingIntegrationTest
|
||||
}
|
||||
// sharer has own invitation message and response
|
||||
assertEquals(2, db0.transactionWithResult(true, txn ->
|
||||
forumSharingManager0.getMessageHeaders(txn, contactId1From0)).size());
|
||||
forumSharingManager0.getMessageHeaders(txn, contactId1From0))
|
||||
.size());
|
||||
// forum can not be shared again
|
||||
Contact c1 = contactManager0.getContact(contactId1From0);
|
||||
assertFalse(forumSharingManager0.canBeShared(forum0.getId(), c1));
|
||||
@@ -209,7 +210,8 @@ public class ForumSharingIntegrationTest
|
||||
}
|
||||
// sharer has own invitation message and response
|
||||
assertEquals(2, db0.transactionWithResult(true, txn ->
|
||||
forumSharingManager0.getMessageHeaders(txn, contactId1From0)).size());
|
||||
forumSharingManager0.getMessageHeaders(txn, contactId1From0))
|
||||
.size());
|
||||
// forum can be shared again
|
||||
Contact c1 = contactManager0.getContact(contactId1From0);
|
||||
assertTrue(forumSharingManager0.canBeShared(forum0.getId(), c1));
|
||||
@@ -736,8 +738,9 @@ public class ForumSharingIntegrationTest
|
||||
|
||||
// get invitation MessageId for later
|
||||
MessageId invitationId = null;
|
||||
Collection<ConversationMessageHeader> list = db1.transactionWithResult(true,
|
||||
txn -> forumSharingManager1.getMessageHeaders(txn, contactId0From1));
|
||||
Collection<ConversationMessageHeader> list =
|
||||
db1.transactionWithResult(true, txn -> forumSharingManager1
|
||||
.getMessageHeaders(txn, contactId0From1));
|
||||
for (ConversationMessageHeader m : list) {
|
||||
if (m instanceof ForumInvitationRequest) {
|
||||
invitationId = m.getId();
|
||||
|
||||
Reference in New Issue
Block a user