mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 15:19:53 +01:00
Fixed crash caused by using DB too early in lifecycle.
This commit is contained in:
@@ -27,5 +27,5 @@ public interface ValidationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Sets the message validator for the given client. */
|
/** Sets the message validator for the given client. */
|
||||||
void setMessageValidator(ClientId c, MessageValidator v);
|
void registerMessageValidator(ClientId c, MessageValidator v);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class ForumModule extends AbstractModule {
|
|||||||
ForumPostValidator validator = new ForumPostValidator(crypto,
|
ForumPostValidator validator = new ForumPostValidator(crypto,
|
||||||
bdfReaderFactory, bdfWriterFactory, authorReader,
|
bdfReaderFactory, bdfWriterFactory, authorReader,
|
||||||
metadataEncoder, clock);
|
metadataEncoder, clock);
|
||||||
validationManager.setMessageValidator(forumManager.getClientId(),
|
validationManager.registerMessageValidator(forumManager.getClientId(),
|
||||||
validator);
|
validator);
|
||||||
return validator;
|
return validator;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ public class MessagingModule extends AbstractModule {
|
|||||||
Clock clock) {
|
Clock clock) {
|
||||||
PrivateMessageValidator validator = new PrivateMessageValidator(
|
PrivateMessageValidator validator = new PrivateMessageValidator(
|
||||||
bdfReaderFactory, metadataEncoder, clock);
|
bdfReaderFactory, metadataEncoder, clock);
|
||||||
validationManager.setMessageValidator(messagingManager.getClientId(),
|
validationManager.registerMessageValidator(
|
||||||
|
messagingManager.getClientId(),
|
||||||
validator);
|
validator);
|
||||||
return validator;
|
return validator;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.briarproject.api.data.ObjectReader;
|
|||||||
import org.briarproject.api.event.EventBus;
|
import org.briarproject.api.event.EventBus;
|
||||||
import org.briarproject.api.identity.Author;
|
import org.briarproject.api.identity.Author;
|
||||||
import org.briarproject.api.identity.AuthorFactory;
|
import org.briarproject.api.identity.AuthorFactory;
|
||||||
|
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||||
import org.briarproject.api.sync.Group;
|
import org.briarproject.api.sync.Group;
|
||||||
import org.briarproject.api.sync.GroupFactory;
|
import org.briarproject.api.sync.GroupFactory;
|
||||||
import org.briarproject.api.sync.MessageFactory;
|
import org.briarproject.api.sync.MessageFactory;
|
||||||
@@ -48,8 +49,9 @@ public class SyncModule extends AbstractModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Provides @Singleton
|
@Provides @Singleton
|
||||||
ValidationManager getValidationManager(EventBus eventBus,
|
ValidationManager getValidationManager(LifecycleManager lifecycleManager,
|
||||||
ValidationManagerImpl validationManager) {
|
EventBus eventBus, ValidationManagerImpl validationManager) {
|
||||||
|
lifecycleManager.register(validationManager);
|
||||||
eventBus.addListener(validationManager);
|
eventBus.addListener(validationManager);
|
||||||
return validationManager;
|
return validationManager;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import org.briarproject.api.db.NoSuchSubscriptionException;
|
|||||||
import org.briarproject.api.event.Event;
|
import org.briarproject.api.event.Event;
|
||||||
import org.briarproject.api.event.EventListener;
|
import org.briarproject.api.event.EventListener;
|
||||||
import org.briarproject.api.event.MessageAddedEvent;
|
import org.briarproject.api.event.MessageAddedEvent;
|
||||||
|
import org.briarproject.api.lifecycle.Service;
|
||||||
import org.briarproject.api.sync.ClientId;
|
import org.briarproject.api.sync.ClientId;
|
||||||
import org.briarproject.api.sync.GroupId;
|
import org.briarproject.api.sync.GroupId;
|
||||||
import org.briarproject.api.sync.Message;
|
import org.briarproject.api.sync.Message;
|
||||||
@@ -29,7 +30,8 @@ import java.util.logging.Logger;
|
|||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
import static org.briarproject.api.sync.SyncConstants.MESSAGE_HEADER_LENGTH;
|
import static org.briarproject.api.sync.SyncConstants.MESSAGE_HEADER_LENGTH;
|
||||||
|
|
||||||
class ValidationManagerImpl implements ValidationManager, EventListener {
|
class ValidationManagerImpl implements ValidationManager, Service,
|
||||||
|
EventListener {
|
||||||
|
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(ValidationManagerImpl.class.getName());
|
Logger.getLogger(ValidationManagerImpl.class.getName());
|
||||||
@@ -50,9 +52,19 @@ class ValidationManagerImpl implements ValidationManager, EventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMessageValidator(ClientId c, MessageValidator v) {
|
public boolean start() {
|
||||||
|
for (ClientId c : validators.keySet()) getMessagesToValidate(c);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean stop() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerMessageValidator(ClientId c, MessageValidator v) {
|
||||||
validators.put(c, v);
|
validators.put(c, v);
|
||||||
getMessagesToValidate(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getMessagesToValidate(final ClientId c) {
|
private void getMessagesToValidate(final ClientId c) {
|
||||||
|
|||||||
Reference in New Issue
Block a user