You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2021/01/29 03:09:08 UTC
[james-project] 08/13: JAMES-3494 fix compilation issues
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 e592c4913388c9ba3c0f1fea60c15b737b186197
Author: RĂ©mi Kowalski <rk...@linagora.com>
AuthorDate: Mon Jan 25 15:51:40 2021 +0100
JAMES-3494 fix compilation issues
---
.../apache/james/eventsourcing/CommandDispatcher.scala | 11 ++++++-----
.../blob/deduplication/DeDuplicationBlobStore.scala | 16 +++++++++++-----
.../org/apache/james/jmap/method/EmailGetMethod.scala | 2 +-
.../james/jmap/method/EmailSetUpdatePerformer.scala | 6 ++----
.../james/jmap/method/EmailSubmissionSetMethod.scala | 2 +-
.../org/apache/james/jmap/method/MailboxGetMethod.scala | 2 +-
.../james/jmap/method/MailboxSetCreatePerformer.scala | 2 +-
.../james/jmap/method/VacationResponseGetMethod.scala | 2 +-
.../scala/org/apache/james/jmap/routes/JmapApi.scala | 2 +-
9 files changed, 25 insertions(+), 20 deletions(-)
diff --git a/event-sourcing/event-sourcing-core/src/main/scala/org/apache/james/eventsourcing/CommandDispatcher.scala b/event-sourcing/event-sourcing-core/src/main/scala/org/apache/james/eventsourcing/CommandDispatcher.scala
index a547bc4..ce2e40c 100644
--- a/event-sourcing/event-sourcing-core/src/main/scala/org/apache/james/eventsourcing/CommandDispatcher.scala
+++ b/event-sourcing/event-sourcing-core/src/main/scala/org/apache/james/eventsourcing/CommandDispatcher.scala
@@ -19,12 +19,13 @@
package org.apache.james.eventsourcing
import java.util
-
import com.google.common.base.Preconditions
+
import javax.inject.Inject
import org.apache.james.eventsourcing.eventstore.EventStoreFailedException
import org.reactivestreams.Publisher
import reactor.core.scala.publisher.SMono
+import reactor.util.retry.Retry
import scala.jdk.CollectionConverters._
@@ -51,11 +52,11 @@ class CommandDispatcher @Inject()(eventBus: EventBus, handlers: Set[CommandHandl
def dispatch(c: Command): Publisher[util.List[_ <: Event]] = {
tryDispatch(c)
- .retry(CommandDispatcher.MAX_RETRY, {
+ .retryWhen(Retry.max(CommandDispatcher.MAX_RETRY)
+ .filter {
case _: EventStoreFailedException => true
case _ => false
- })
- .onErrorMap({
+ }).onErrorMap({
case _: EventStoreFailedException => CommandDispatcher.TooManyRetries(c, CommandDispatcher.MAX_RETRY)
case error => error
})
@@ -75,7 +76,7 @@ class CommandDispatcher @Inject()(eventBus: EventBus, handlers: Set[CommandHandl
SMono(eventsPublisher)
.flatMap(events => eventBus.publish(events.asScala).`then`(SMono.just(events)))
case _ =>
- SMono.raiseError(CommandDispatcher.UnknownCommandException(c))
+ SMono.error(CommandDispatcher.UnknownCommandException(c))
}
}
diff --git a/server/blob/blob-storage-strategy/src/main/scala/org/apache/james/server/blob/deduplication/DeDuplicationBlobStore.scala b/server/blob/blob-storage-strategy/src/main/scala/org/apache/james/server/blob/deduplication/DeDuplicationBlobStore.scala
index 6cab727..a32bdff 100644
--- a/server/blob/blob-storage-strategy/src/main/scala/org/apache/james/server/blob/deduplication/DeDuplicationBlobStore.scala
+++ b/server/blob/blob-storage-strategy/src/main/scala/org/apache/james/server/blob/deduplication/DeDuplicationBlobStore.scala
@@ -20,10 +20,11 @@
package org.apache.james.server.blob.deduplication
import java.io.InputStream
-
+import java.util.concurrent.Callable
import com.google.common.base.Preconditions
import com.google.common.hash.{Hashing, HashingInputStream}
import com.google.common.io.{ByteSource, FileBackedOutputStream}
+
import javax.inject.{Inject, Named}
import org.apache.commons.io.IOUtils
import org.apache.james.blob.api.{BlobId, BlobStore, BlobStoreDAO, BucketName}
@@ -32,6 +33,8 @@ import reactor.core.publisher.Mono
import reactor.core.scala.publisher.SMono
import reactor.util.function.{Tuple2, Tuples}
+import scala.compat.java8.FunctionConverters._
+
object DeDuplicationBlobStore {
val DEFAULT_BUCKET = "defaultBucket"
val LAZY_RESOURCE_CLEANUP = false
@@ -56,10 +59,13 @@ class DeDuplicationBlobStore @Inject()(blobStoreDAO: BlobStoreDAO,
Preconditions.checkNotNull(bucketName)
Preconditions.checkNotNull(data)
val hashingInputStream = new HashingInputStream(Hashing.sha256, data)
- val sourceSupplier: FileBackedOutputStream => SMono[BlobId] = (fileBackedOutputStream: FileBackedOutputStream) => saveAndGenerateBlobId(bucketName, hashingInputStream, fileBackedOutputStream)
- Mono.using(() => new FileBackedOutputStream(DeDuplicationBlobStore.FILE_THRESHOLD),
- sourceSupplier,
- (fileBackedOutputStream: FileBackedOutputStream) => fileBackedOutputStream.reset(),
+ val sourceSupplier: FileBackedOutputStream => Mono[BlobId] = (fileBackedOutputStream: FileBackedOutputStream) => saveAndGenerateBlobId(bucketName, hashingInputStream, fileBackedOutputStream).asJava()
+ val ressourceSupplier: Callable[FileBackedOutputStream] = () => new FileBackedOutputStream(DeDuplicationBlobStore.FILE_THRESHOLD)
+
+ Mono.using(
+ ressourceSupplier,
+ sourceSupplier.asJava,
+ ((fileBackedOutputStream: FileBackedOutputStream) => fileBackedOutputStream.reset()).asJava,
DeDuplicationBlobStore.LAZY_RESOURCE_CLEANUP)
}
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailGetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailGetMethod.scala
index 3ee9579..736b656 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailGetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailGetMethod.scala
@@ -167,7 +167,7 @@ class EmailGetMethod @Inject() (readerFactory: EmailViewReaderFactory,
}))
SFlux.merge(Seq(retrieveEmails(messagesIds, mailboxSession, request), parsingErrors))
- .reduce(EmailGetResults.empty(), EmailGetResults.merge)
+ .reduce(EmailGetResults.empty())(EmailGetResults.merge)
}
private def asMessageId(id: UnparsedEmailId): Either[(UnparsedEmailId, IllegalArgumentException), MessageId] =
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSetUpdatePerformer.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSetUpdatePerformer.scala
index 8f11639..d40273b 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSetUpdatePerformer.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSetUpdatePerformer.scala
@@ -169,8 +169,7 @@ class EmailSetUpdatePerformer @Inject() (serializer: EmailSetSerializer,
private def updateByRange(ranges: List[MessageRange],
metaData: Map[MessageId, Traversable[ComposedMessageIdWithMetaData]],
- operation: Consumer[MessageRange]): SMono[Seq[EmailUpdateResult]] = {
-
+ operation: Consumer[MessageRange]): SMono[Seq[EmailUpdateResult]] =
SFlux.fromIterable(ranges)
.concatMap(range => {
val messageIds = metaData.filter(entry => entry._2.exists(composedId => range.includes(composedId.getComposedMessageId.getUid)))
@@ -183,8 +182,7 @@ class EmailSetUpdatePerformer @Inject() (serializer: EmailSetSerializer,
.onErrorResume(e => SMono.just(messageIds.map(id => EmailUpdateFailure(EmailSet.asUnparsed(id), e))))
.subscribeOn(Schedulers.elastic())
})
- .reduce(Seq(), _ ++ _)
- }
+ .reduce(Seq[EmailUpdateResult]())( _ ++ _)
private def updateEachMessage(validUpdates: List[(MessageId, ValidatedEmailSetUpdate)],
metaData: Map[MessageId, Traversable[ComposedMessageIdWithMetaData]],
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala
index b5791b4..e63e283 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala
@@ -162,7 +162,7 @@ class EmailSubmissionSetMethod @Inject()(serializer: EmailSubmissionSetSerialize
SFlux.fromIterable(request.create
.getOrElse(Map.empty)
.view)
- .foldLeft((CreationResults(Nil), processingContext)) {
+ .fold((CreationResults(Nil), processingContext)) {
(acc : (CreationResults, ProcessingContext), elem: (EmailSubmissionCreationId, JsObject)) => {
val (emailSubmissionCreationId, jsObject) = elem
val (creationResult, updatedProcessingContext) = createSubmission(session, emailSubmissionCreationId, jsObject, acc._2)
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxGetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxGetMethod.scala
index dc7f123..04cd1f8 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxGetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxGetMethod.scala
@@ -79,7 +79,7 @@ class MailboxGetMethod @Inject() (serializer: MailboxSerializer,
val requestedProperties: Properties = request.properties.getOrElse(Mailbox.allProperties)
(requestedProperties -- Mailbox.allProperties match {
case invalidProperties if invalidProperties.isEmpty() => getMailboxes(capabilities, request, mailboxSession)
- .reduce(MailboxGetResults.empty(), MailboxGetResults.merge)
+ .reduce(MailboxGetResults.empty())(MailboxGetResults.merge)
.flatMap(mailboxes => retrieveState(capabilities, mailboxSession)
.map(state => mailboxes.asResponse(request.accountId, state)))
.map(mailboxGetResponse => Invocation(
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetCreatePerformer.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetCreatePerformer.scala
index 4fe260a..e9db0ef 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetCreatePerformer.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetCreatePerformer.scala
@@ -88,7 +88,7 @@ class MailboxSetCreatePerformer @Inject()(serializer: MailboxSerializer,
SFlux.fromIterable(mailboxSetRequest.create
.getOrElse(Map.empty)
.view)
- .foldLeft((MailboxCreationResults(Nil), processingContext)){
+ .fold((MailboxCreationResults(Nil), processingContext)){
(acc : (MailboxCreationResults, ProcessingContext), elem: (MailboxCreationId, JsObject)) => {
val (mailboxCreationId, jsObject) = elem
val (creationResult, updatedProcessingContext) = createMailbox(mailboxSession, mailboxCreationId, jsObject, acc._2)
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/VacationResponseGetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/VacationResponseGetMethod.scala
index 0bdcb31..6683f84 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/VacationResponseGetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/VacationResponseGetMethod.scala
@@ -67,7 +67,7 @@ class VacationResponseGetMethod @Inject()(vacationRepository: VacationRepository
val requestedProperties: Properties = request.properties.getOrElse(VacationResponse.allProperties)
(requestedProperties -- VacationResponse.allProperties match {
case invalidProperties if invalidProperties.isEmpty() => getVacationResponse(request, mailboxSession)
- .reduce(VacationResponseGetResult.empty, VacationResponseGetResult.merge)
+ .reduce(VacationResponseGetResult.empty)(VacationResponseGetResult.merge)
.map(vacationResult => vacationResult.asResponse(request.accountId))
.map(vacationResponseGetResponse => Invocation(
methodName = methodName,
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/JmapApi.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/JmapApi.scala
index a8ca359..65a0320 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/JmapApi.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/JmapApi.scala
@@ -59,7 +59,7 @@ class JMAPApi (methods: Set[Method], defaultCapabilities: Set[Capability]) {
private def processSequentiallyAndUpdateContext(requestObject: RequestObject, mailboxSession: MailboxSession, processingContext: ProcessingContext, capabilities: Set[CapabilityIdentifier]): SMono[Seq[(InvocationWithContext)]] =
SFlux.fromIterable(requestObject.methodCalls)
- .foldLeft(List[SFlux[InvocationWithContext]]())((acc, elem) => {
+ .fold(List[SFlux[InvocationWithContext]]())((acc, elem) => {
val lastProcessingContext: SMono[ProcessingContext] = acc.headOption
.map(last => SMono.fromPublisher(Flux.from(last.map(_.processingContext)).last()))
.getOrElse(SMono.just(processingContext))
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org