This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/master by this push: new 563de4b078 [FIX] GroupRegistrationHandler's scheduler should be final 563de4b078 is described below commit 563de4b078cfd13eaae1d63ff90ff4442925c3c5 Author: Quan Tran <hqt...@linagora.com> AuthorDate: Fri Apr 19 17:18:06 2024 +0700 [FIX] GroupRegistrationHandler's scheduler should be final And be initialized in the constructor. Given the RabbitMQEventBus beans are limited and the group use case is soon or late being used, we do not need lazy initialization for the scheduler IMO. Otherwise, James could restart the `GroupRegistrationHandler` while it is not started yet (e.g. a RabbitMQ node is down before any group listener is registered) which leads to `java.lang.NullPointerException: scheduler` and fail the `RabbitEventBusConsumerHealthCheck`. --- .../main/java/org/apache/james/events/GroupRegistrationHandler.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/event-bus/distributed/src/main/java/org/apache/james/events/GroupRegistrationHandler.java b/event-bus/distributed/src/main/java/org/apache/james/events/GroupRegistrationHandler.java index 98b006dc19..63818517d2 100644 --- a/event-bus/distributed/src/main/java/org/apache/james/events/GroupRegistrationHandler.java +++ b/event-bus/distributed/src/main/java/org/apache/james/events/GroupRegistrationHandler.java @@ -77,7 +77,7 @@ class GroupRegistrationHandler { private final ListenerExecutor listenerExecutor; private final RabbitMQConfiguration configuration; private final GroupRegistration.WorkQueueName queueName; - private Scheduler scheduler; + private final Scheduler scheduler; private Optional<Disposable> consumer; GroupRegistrationHandler(NamingStrategy namingStrategy, EventSerializer eventSerializer, ReactorRabbitMQChannelPool channelPool, Sender sender, ReceiverProvider receiverProvider, @@ -94,8 +94,8 @@ class GroupRegistrationHandler { this.configuration = configuration; this.groupRegistrations = new ConcurrentHashMap<>(); this.queueName = namingStrategy.workQueue(GROUP); + this.scheduler = Schedulers.newBoundedElastic(EventBus.EXECUTION_RATE, ReactorUtils.DEFAULT_BOUNDED_ELASTIC_QUEUESIZE, "groups-handler"); this.consumer = Optional.empty(); - } GroupRegistration retrieveGroupRegistration(Group group) { @@ -104,7 +104,6 @@ class GroupRegistrationHandler { } public void start() { - scheduler = Schedulers.newBoundedElastic(EventBus.EXECUTION_RATE, ReactorUtils.DEFAULT_BOUNDED_ELASTIC_QUEUESIZE, "groups-handler"); channelPool.createWorkQueue( QueueSpecification.queue(queueName.asString()) .durable(DURABLE) --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org