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
commit 0cb375f4a24397c5fa72346e075118c63bad8a67 Author: Benoit Tellier <btell...@linagora.com> AuthorDate: Tue May 12 11:40:31 2020 +0700 [REFACTORING] Rely on Flux::flatMapIterable This enables reactor to know it can synchronously expend the iterable without needing asynchronous execution --- .../james/mailbox/cassandra/mail/CassandraMessageIdMapper.java | 4 +++- .../src/main/java/org/apache/james/PeriodicalHealthChecks.java | 4 ++-- .../jmap/api/filtering/impl/EventSourcingFilteringManagement.java | 3 +-- .../james/dlp/eventsourcing/EventSourcingDLPConfigurationStore.java | 3 +-- .../apache/james/jmap/draft/methods/GetVacationResponseMethod.java | 5 +++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java index 281fb2b..f98090a 100644 --- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java +++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java @@ -22,6 +22,7 @@ import java.time.Duration; import java.util.Collection; import java.util.List; import java.util.Optional; +import java.util.function.Function; import javax.mail.Flags; @@ -251,7 +252,8 @@ public class CassandraMessageIdMapper implements MessageIdMapper { LOGGER.info("Mailbox {} was deleted during flag update", mailboxId); return Mono.empty(); }) - .flatMapMany(Flux::fromIterable) + .flux() + .flatMapIterable(Function.identity()) .map(pair -> buildUpdatedFlags(pair.getRight(), pair.getLeft())); } diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/PeriodicalHealthChecks.java b/server/container/guice/guice-common/src/main/java/org/apache/james/PeriodicalHealthChecks.java index c51efdf..dedddca 100644 --- a/server/container/guice/guice-common/src/main/java/org/apache/james/PeriodicalHealthChecks.java +++ b/server/container/guice/guice-common/src/main/java/org/apache/james/PeriodicalHealthChecks.java @@ -59,8 +59,8 @@ public class PeriodicalHealthChecks implements Startable { public void start() { disposable = Flux.interval(configuration.getPeriod(), scheduler) - .flatMap(any -> Flux.fromIterable(healthChecks) - .flatMap(healthCheck -> Mono.from(healthCheck.check()))) + .flatMapIterable(any -> healthChecks) + .flatMap(healthCheck -> Mono.from(healthCheck.check())) .doOnNext(this::logResult) .onErrorContinue(this::logError) .subscribeOn(Schedulers.elastic()) diff --git a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/impl/EventSourcingFilteringManagement.java b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/impl/EventSourcingFilteringManagement.java index 72af24d..662fad1 100644 --- a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/impl/EventSourcingFilteringManagement.java +++ b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/impl/EventSourcingFilteringManagement.java @@ -34,7 +34,6 @@ import org.reactivestreams.Publisher; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; -import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; public class EventSourcingFilteringManagement implements FilteringManagement { @@ -65,6 +64,6 @@ public class EventSourcingFilteringManagement implements FilteringManagement { FilteringAggregateId aggregateId = new FilteringAggregateId(username); return Mono.from(eventStore.getEventsOfAggregate(aggregateId)) - .flatMapMany(history -> Flux.fromIterable(FilteringAggregate.load(aggregateId, history).listRules())); + .flatMapIterable(history -> FilteringAggregate.load(aggregateId, history).listRules()); } } diff --git a/server/data/data-library/src/main/java/org/apache/james/dlp/eventsourcing/EventSourcingDLPConfigurationStore.java b/server/data/data-library/src/main/java/org/apache/james/dlp/eventsourcing/EventSourcingDLPConfigurationStore.java index 48d88ba..7a6140b 100644 --- a/server/data/data-library/src/main/java/org/apache/james/dlp/eventsourcing/EventSourcingDLPConfigurationStore.java +++ b/server/data/data-library/src/main/java/org/apache/james/dlp/eventsourcing/EventSourcingDLPConfigurationStore.java @@ -41,7 +41,6 @@ import org.reactivestreams.Publisher; import com.google.common.collect.ImmutableSet; -import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; public class EventSourcingDLPConfigurationStore implements DLPConfigurationStore { @@ -84,7 +83,7 @@ public class EventSourcingDLPConfigurationStore implements DLPConfigurationStore @Override public Optional<DLPConfigurationItem> fetch(Domain domain, Id ruleId) { return Mono.from(list(domain)) - .flatMapMany(rules -> Flux.fromIterable(rules.getItems())) + .flatMapIterable(DLPRules::getItems) .toStream() .filter((DLPConfigurationItem item) -> item.getId().equals(ruleId)) .findFirst(); diff --git a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/GetVacationResponseMethod.java b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/GetVacationResponseMethod.java index da38ebd..da9f326 100644 --- a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/GetVacationResponseMethod.java +++ b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/GetVacationResponseMethod.java @@ -74,11 +74,12 @@ public class GetVacationResponseMethod implements Method { return Flux.from(metricFactory.runPublishingTimerMetricLogP99(JMAP_PREFIX + METHOD_NAME.getName(), process(mailboxSession) - .flatMapMany(response -> Flux.just(JmapResponse.builder() + .map(response -> JmapResponse.builder() .methodCallId(methodCallId) .responseName(RESPONSE_NAME) .response(response) - .build())))) + .build()) + .flux())) .subscriberContext(jmapAction("VACATION")); } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org