mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +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. */
|
||||
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,
|
||||
bdfReaderFactory, bdfWriterFactory, authorReader,
|
||||
metadataEncoder, clock);
|
||||
validationManager.setMessageValidator(forumManager.getClientId(),
|
||||
validationManager.registerMessageValidator(forumManager.getClientId(),
|
||||
validator);
|
||||
return validator;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ public class MessagingModule extends AbstractModule {
|
||||
Clock clock) {
|
||||
PrivateMessageValidator validator = new PrivateMessageValidator(
|
||||
bdfReaderFactory, metadataEncoder, clock);
|
||||
validationManager.setMessageValidator(messagingManager.getClientId(),
|
||||
validationManager.registerMessageValidator(
|
||||
messagingManager.getClientId(),
|
||||
validator);
|
||||
return validator;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.briarproject.api.data.ObjectReader;
|
||||
import org.briarproject.api.event.EventBus;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.identity.AuthorFactory;
|
||||
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupFactory;
|
||||
import org.briarproject.api.sync.MessageFactory;
|
||||
@@ -48,8 +49,9 @@ public class SyncModule extends AbstractModule {
|
||||
}
|
||||
|
||||
@Provides @Singleton
|
||||
ValidationManager getValidationManager(EventBus eventBus,
|
||||
ValidationManagerImpl validationManager) {
|
||||
ValidationManager getValidationManager(LifecycleManager lifecycleManager,
|
||||
EventBus eventBus, ValidationManagerImpl validationManager) {
|
||||
lifecycleManager.register(validationManager);
|
||||
eventBus.addListener(validationManager);
|
||||
return validationManager;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.briarproject.api.db.NoSuchSubscriptionException;
|
||||
import org.briarproject.api.event.Event;
|
||||
import org.briarproject.api.event.EventListener;
|
||||
import org.briarproject.api.event.MessageAddedEvent;
|
||||
import org.briarproject.api.lifecycle.Service;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.Message;
|
||||
@@ -29,7 +30,8 @@ import java.util.logging.Logger;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
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 =
|
||||
Logger.getLogger(ValidationManagerImpl.class.getName());
|
||||
@@ -50,9 +52,19 @@ class ValidationManagerImpl implements ValidationManager, EventListener {
|
||||
}
|
||||
|
||||
@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);
|
||||
getMessagesToValidate(c);
|
||||
}
|
||||
|
||||
private void getMessagesToValidate(final ClientId c) {
|
||||
|
||||
Reference in New Issue
Block a user