You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2022/06/08 02:43:04 UTC
[james-project] branch master updated (1dcc121559 -> 4d81469a4d)
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
from 1dcc121559 [REACTOR] TerminationSubscriber don't require a subscriber switch
new 0a63510976 Tiny performance enhancement for JMAP RFC-8621
new 907cba24f0 [PERF] Optimize further Email/get serialization
new df39e8767c [PERF] Optimize further Mailbox/get serialization
new 69d8652cb0 [PERF] Optimize further response serialization
new c136dca90b [PERF] OSlightly improve Email/query deserialization
new 4d81469a4d [PERF] RequestObject::using is better suited as a set
The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../org/apache/james/jmap/core/Properties.scala | 14 +++----
.../org/apache/james/jmap/core/RequestObject.scala | 2 +-
.../james/jmap/json/EmailGetSerializer.scala | 47 +++++++++++++++-------
.../james/jmap/json/MailboxQuerySerializer.scala | 8 ++--
.../apache/james/jmap/json/MailboxSerializer.scala | 8 ++--
.../james/jmap/json/ResponseSerializer.scala | 10 ++---
.../scala/org/apache/james/jmap/mail/Mailbox.scala | 5 ++-
.../org/apache/james/jmap/routes/JmapApi.scala | 4 +-
.../jmap/json/RequestObjectSerializationTest.scala | 10 ++---
9 files changed, 62 insertions(+), 46 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[james-project] 01/06: Tiny performance enhancement for JMAP RFC-8621
Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 0a63510976d8ea4bf737c0170fbb03f2b90cd214
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat Jun 4 13:09:14 2022 +0700
Tiny performance enhancement for JMAP RFC-8621
---
.../main/scala/org/apache/james/jmap/core/Properties.scala | 14 +++++++-------
.../org/apache/james/jmap/json/EmailGetSerializer.scala | 8 ++++----
.../org/apache/james/jmap/json/ResponseSerializer.scala | 2 +-
.../main/scala/org/apache/james/jmap/mail/Mailbox.scala | 5 +++--
4 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/Properties.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/Properties.scala
index b182225dd5..b0373ed631 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/Properties.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/Properties.scala
@@ -19,6 +19,7 @@
package org.apache.james.jmap.core
+import eu.timepit.refined.api.Refined
import eu.timepit.refined.collection.NonEmpty
import eu.timepit.refined.refineV
import eu.timepit.refined.types.string.NonEmptyString
@@ -50,14 +51,13 @@ case class Properties(value: Set[NonEmptyString]) {
def isEmpty(): Boolean = value.isEmpty
def contains(property: NonEmptyString): Boolean = value.contains(property)
- def containsString(property: String): Boolean = refineV[NonEmpty](property).fold(e => false, refined => contains(refined))
+
+ def containsString(property: String): Boolean = {
+ val refined: NonEmptyString = Refined.unsafeApply(property)
+ contains(refined)
+ }
def format(): String = value.mkString(", ")
- def filter(o: JsObject): JsObject =
- JsObject(o.fields.filter(entry => {
- val refined: Either[String, NonEmptyString] = refineV[NonEmpty](entry._1)
- refined.fold(e => throw new RuntimeException(e),
- property => value.contains(property))
- }))
+ def filter(o: JsObject): JsObject = JsObject(o.value.filter(entry => containsString(entry._1)))
}
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/EmailGetSerializer.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/EmailGetSerializer.scala
index 00503e17a3..e866f834c3 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/EmailGetSerializer.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/EmailGetSerializer.scala
@@ -69,7 +69,7 @@ object EmailGetSerializer {
private implicit val cidWrites: Writes[Cid] = cid => JsString(cid.getValue)
private implicit val nameWrites: Writes[Name] = Json.valueWrites[Name]
private implicit val threadIdWrites: Writes[ThreadId] = Json.valueWrites[ThreadId]
- private implicit val mailboxIdsWrites: Writes[MailboxIds] = ids => JsObject(ids.value.map(id => (id.serialize(), JsBoolean(true))))
+ private implicit val mailboxIdsWrites: Writes[MailboxIds] = ids => JsObject(ids.value.map(id => (id.serialize(), JsTrue)))
private implicit val typeWrites: Writes[Type] = Json.valueWrites[Type]
private implicit val charsetWrites: Writes[Charset] = Json.valueWrites[Charset]
private implicit val dispositionWrites: Writes[Disposition] = Json.valueWrites[Disposition]
@@ -193,7 +193,7 @@ object EmailGetSerializer {
}).get
private def bodyPropertiesFilteringTransformation(bodyProperties: Properties): Reads[JsValue] = {
- case serializedMailbox: JsObject =>
+ case serializedBody: JsObject =>
val bodyPropertiesToRemove = EmailBodyPart.allowedProperties -- bodyProperties
val noop: JsValue => JsValue = o => o
@@ -204,13 +204,13 @@ object EmailGetSerializer {
bodyPropertiesFilteringTransformation(bodyPropertiesToRemove, "htmlBody"))
.reduceLeftOption(_ compose _)
.getOrElse(noop)
- .apply(serializedMailbox))
+ .apply(serializedBody))
case js => JsSuccess(js)
}
private def bodyPropertiesFilteringTransformation(properties: Properties, field: String): JsValue => JsValue =
{
- case JsObject(underlying) =>JsObject(underlying.map {
+ case JsObject(underlying) => JsObject(underlying.map {
case (key, jsValue) if key.equals(field) => (field, removeFieldsRecursively(properties).apply(jsValue))
case (key, jsValue) => (key, jsValue)
})
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala
index c48df7fb2f..332c38b72f 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala
@@ -60,7 +60,7 @@ object ResponseSerializer {
) (core.Invocation.apply _)
private implicit val invocationWrite: Writes[Invocation] = (invocation: Invocation) =>
- Json.arr(invocation.methodName, invocation.arguments, invocation.methodCallId)
+ JsArray(Seq(JsString(invocation.methodName.value.value), invocation.arguments.value, JsString(invocation.methodCallId.value.value)))
private implicit val statusWrite: Writes[HttpResponseStatus] = status => JsNumber(status.code())
// RequestObject
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/Mailbox.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/Mailbox.scala
index e8f1187c8d..2b72150a86 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/Mailbox.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/Mailbox.scala
@@ -143,9 +143,10 @@ object Mailbox {
CapabilityIdentifier.JAMES_SHARES -> Properties("namespace", "rights"))
def propertiesFiltered(requestedProperties: Properties, allowedCapabilities : Set[CapabilityIdentifier]) : Properties = {
- val propertiesToHide: Properties = propertiesForCapabilities.filterNot(entry => allowedCapabilities.contains(entry._1))
+ val propertiesToHide: Properties = Properties(propertiesForCapabilities.filterNot(entry => allowedCapabilities.contains(entry._1))
.values
- .fold(Properties.empty())(_ ++ _)
+ .flatMap(p => p.value)
+ .toSet)
(idProperty ++ requestedProperties) -- propertiesToHide
}
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[james-project] 02/06: [PERF] Optimize further Email/get serialization
Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 907cba24f06f65df89a5342a3628741b2fd584cd
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Jun 6 11:20:38 2022 +0700
[PERF] Optimize further Email/get serialization
- Avoid computing body transformation when not needed
- Avoid computing body transformation for each item
---
.../james/jmap/json/EmailGetSerializer.scala | 39 ++++++++++++++++------
1 file changed, 28 insertions(+), 11 deletions(-)
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/EmailGetSerializer.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/EmailGetSerializer.scala
index e866f834c3..a247daa1e2 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/EmailGetSerializer.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/EmailGetSerializer.scala
@@ -20,6 +20,7 @@
package org.apache.james.jmap.json
import eu.timepit.refined
+import eu.timepit.refined.auto._
import org.apache.james.jmap.api.model.Size.Size
import org.apache.james.jmap.api.model.{EmailAddress, EmailerName, Preview}
import org.apache.james.jmap.core.Id.IdConstraint
@@ -180,17 +181,33 @@ object EmailGetSerializer {
def serializeChanges(changesResponse: EmailChangesResponse): JsObject = Json.toJson(changesResponse).as[JsObject]
- def serialize(emailGetResponse: EmailGetResponse, properties: Properties, bodyProperties: Properties): JsValue =
- Json.toJson(emailGetResponse)
- .transform((__ \ "list").json.update {
- case JsArray(underlying) => JsSuccess(JsArray(underlying.map(js => js.transform {
- case jsonObject: JsObject =>
- bodyPropertiesFilteringTransformation(bodyProperties)
- .reads(properties.filter(jsonObject))
- case js => JsSuccess(js)
- }.fold(_ => JsArray(underlying), o => o))))
- case jsValue => JsSuccess(jsValue)
- }).get
+ def serialize(emailGetResponse: EmailGetResponse, properties: Properties, bodyProperties: Properties): JsValue = {
+ if (includesBodyProperties(properties)) {
+ val bodyTransformation = bodyPropertiesFilteringTransformation(bodyProperties)
+ Json.toJson(emailGetResponse)
+ .transform((__ \ "list").json.update {
+ case JsArray(underlying) => JsSuccess(JsArray(underlying.map(js => js.transform {
+ case jsonObject: JsObject => bodyTransformation.reads(properties.filter(jsonObject))
+ case js => JsSuccess(js)
+ }.fold(_ => JsArray(underlying), o => o))))
+ case jsValue => JsSuccess(jsValue)
+ }).get
+ } else
+ Json.toJson(emailGetResponse)
+ .transform((__ \ "list").json.update {
+ case JsArray(underlying) => JsSuccess(JsArray(underlying.map(js => js.transform {
+ case jsonObject: JsObject => JsSuccess(properties.filter(jsonObject))
+ case js => JsSuccess(js)
+ }.fold(_ => JsArray(underlying), o => o))))
+ case jsValue => JsSuccess(jsValue)
+ }).get
+ }
+
+ private def includesBodyProperties(properties: Properties): Boolean =
+ properties.contains("attachments") ||
+ properties.contains("bodyStructure") ||
+ properties.contains("textBody") ||
+ properties.contains("htmlBody")
private def bodyPropertiesFilteringTransformation(bodyProperties: Properties): Reads[JsValue] = {
case serializedBody: JsObject =>
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[james-project] 04/06: [PERF] Optimize further response serialization
Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 69d8652cb0acd4f3f7b9c9c16cd157f41c989c33
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Jun 6 11:23:39 2022 +0700
[PERF] Optimize further response serialization
One time map instead of complex foldLeft
---
.../scala/org/apache/james/jmap/json/ResponseSerializer.scala | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala
index 332c38b72f..a90eaa57c1 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/ResponseSerializer.scala
@@ -96,10 +96,10 @@ object ResponseSerializer {
val webSocketPropertiesWrites: OWrites[WebSocketCapabilityProperties] = Json.writes[WebSocketCapabilityProperties]
private implicit val setCapabilityWrites: Writes[Set[_ <: Capability]] =
- (set: Set[_ <: Capability]) => {
- set.foldLeft(JsObject.empty)((jsObject, capability) =>
- jsObject.+(capability.identifier.value, capability.properties.jsonify))
- }
+ (set: Set[_ <: Capability]) =>
+ JsObject(set
+ .map(capability => (capability.identifier().value, capability.properties().jsonify()))
+ .toMap)
private implicit val capabilitiesWrites: Writes[Capabilities] = capabilities => setCapabilityWrites.writes(capabilities.capabilities)
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[james-project] 03/06: [PERF] Optimize further Mailbox/get serialization
Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit df39e8767c80ec7a5e32732ef7bcf99d0d131d8a
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Jun 6 11:21:35 2022 +0700
[PERF] Optimize further Mailbox/get serialization
Compute properties filtering once instead of for each item.
---
.../main/scala/org/apache/james/jmap/json/MailboxSerializer.scala | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/MailboxSerializer.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/MailboxSerializer.scala
index 9b7e06ef56..517e5d37d4 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/MailboxSerializer.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/MailboxSerializer.scala
@@ -172,16 +172,16 @@ class MailboxSerializer @Inject()(mailboxIdFactory: MailboxId.Factory) {
def serialize(mailbox: Mailbox): JsValue = Json.toJson(mailbox)
- def serialize(mailboxGetResponse: MailboxGetResponse, properties: Properties, capabilities: Set[CapabilityIdentifier]): JsValue =
+ def serialize(mailboxGetResponse: MailboxGetResponse, properties: Properties, capabilities: Set[CapabilityIdentifier]): JsValue = {
+ val mailboxTransformation = Mailbox.propertiesFiltered(properties, capabilities)
Json.toJson(mailboxGetResponse)
.transform((__ \ "list").json.update {
case JsArray(underlying) => JsSuccess(JsArray(underlying.map {
- case jsonObject: JsObject =>
- Mailbox.propertiesFiltered(properties, capabilities)
- .filter(jsonObject)
+ case jsonObject: JsObject => mailboxTransformation.filter(jsonObject)
case jsValue => jsValue
}))
}).get
+ }
def serialize(mailboxSetResponse: MailboxSetResponse, capabilities: Set[CapabilityIdentifier]): JsValue =
Json.toJson(mailboxSetResponse)
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[james-project] 06/06: [PERF] RequestObject::using is better suited as a set
Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 4d81469a4d6386059449f8a2adc307b2520ad0ec
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Tue Jun 7 13:44:06 2022 +0700
[PERF] RequestObject::using is better suited as a set
It avoids later a double set conversion
---
.../main/scala/org/apache/james/jmap/core/RequestObject.scala | 2 +-
.../src/main/scala/org/apache/james/jmap/routes/JmapApi.scala | 4 ++--
.../james/jmap/json/RequestObjectSerializationTest.scala | 10 +++++-----
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/RequestObject.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/RequestObject.scala
index c612a7e77a..559f7386b4 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/RequestObject.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/RequestObject.scala
@@ -37,4 +37,4 @@ final case class ServerId(value: Id)
case class CreatedIds(value: Map[ClientId, ServerId])
-case class RequestObject(using: Seq[CapabilityIdentifier], methodCalls: Seq[Invocation], createdIds: Option[CreatedIds] = None)
+case class RequestObject(using: Set[CapabilityIdentifier], methodCalls: Seq[Invocation], createdIds: Option[CreatedIds] = None)
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 71cf04e06c..d9c0ae4ce6 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
@@ -46,8 +46,8 @@ class JMAPApi (methods: Set[Method], defaultCapabilities: Set[CapabilityIdentifi
def process(requestObject: RequestObject,
mailboxSession: MailboxSession): SMono[ResponseObject] = {
val processingContext: ProcessingContext = ProcessingContext(Map.empty, Map.empty)
- val unsupportedCapabilities = requestObject.using.toSet -- defaultCapabilities
- val capabilities: Set[CapabilityIdentifier] = requestObject.using.toSet
+ val unsupportedCapabilities = requestObject.using -- defaultCapabilities
+ val capabilities: Set[CapabilityIdentifier] = requestObject.using
if (unsupportedCapabilities.nonEmpty) {
SMono.error(UnsupportedCapabilitiesException(unsupportedCapabilities))
diff --git a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/json/RequestObjectSerializationTest.scala b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/json/RequestObjectSerializationTest.scala
index e53cd3a3ef..42ac8b521c 100644
--- a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/json/RequestObjectSerializationTest.scala
+++ b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/json/RequestObjectSerializationTest.scala
@@ -30,7 +30,7 @@ class RequestObjectSerializationTest extends AnyWordSpec with Matchers {
"Deserialize RequestObject" should {
"succeed when deserialize from JsString without CreatedIds" in {
val expectedRequestObject = RequestObject(
- using = Seq(coreIdentifier),
+ using = Set(coreIdentifier),
methodCalls = Seq(invocation1),
createdIds = Option.empty)
@@ -51,7 +51,7 @@ class RequestObjectSerializationTest extends AnyWordSpec with Matchers {
"succeed when deserialize from JsString with CreatedIds" in {
val expectedRequestObject = RequestObject(
- using = Seq(coreIdentifier),
+ using = Set(coreIdentifier),
methodCalls = Seq(invocation1),
createdIds = Option(createdIds))
@@ -73,7 +73,7 @@ class RequestObjectSerializationTest extends AnyWordSpec with Matchers {
"succeed with many Capability, methodCalls without CreatedIds" in {
val expectedRequestObject = RequestObject(
- using = Seq(coreIdentifier, mailIdentifier),
+ using = Set(coreIdentifier, mailIdentifier),
methodCalls = Seq(invocation1, invocation2),
createdIds = Option.empty)
@@ -101,7 +101,7 @@ class RequestObjectSerializationTest extends AnyWordSpec with Matchers {
"succeed when write to string without CreatedIds" in {
val actualValue = ResponseSerializer.serialize(
RequestObject(
- using = Seq(coreIdentifier, mailIdentifier),
+ using = Set(coreIdentifier, mailIdentifier),
methodCalls = Seq(invocation1),
createdIds = Option.empty))
@@ -124,7 +124,7 @@ class RequestObjectSerializationTest extends AnyWordSpec with Matchers {
"succeed when write to string with CreatedIds" in {
val actualValue = ResponseSerializer.serialize(
RequestObject(
- using = Seq(coreIdentifier, mailIdentifier),
+ using = Set(coreIdentifier, mailIdentifier),
methodCalls = Seq(invocation1),
createdIds = Option(createdIds)))
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[james-project] 05/06: [PERF] OSlightly improve Email/query deserialization
Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit c136dca90b666523abadf56202bf14c735cb4978
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Jun 6 11:24:09 2022 +0700
[PERF] OSlightly improve Email/query deserialization
---
.../scala/org/apache/james/jmap/json/MailboxQuerySerializer.scala | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/MailboxQuerySerializer.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/MailboxQuerySerializer.scala
index 8110aaf69c..b184f6189f 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/MailboxQuerySerializer.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/MailboxQuerySerializer.scala
@@ -33,7 +33,6 @@ object MailboxQuerySerializer {
private implicit val mailboxIdWrites: Writes[MailboxId] = mailboxId => JsString(mailboxId.serialize)
-
private implicit val roleReads: Reads[Role] = {
case JsString(value) => Role.from(value).toScala.map(JsSuccess(_))
.getOrElse(JsError(s"$value is not a valid role"))
@@ -41,14 +40,13 @@ object MailboxQuerySerializer {
}
private implicit val filterReads: Reads[MailboxFilter] = {
- case JsObject(underlying) => {
- val unsupported: collection.Set[String] = underlying.keySet.diff(MailboxFilter.SUPPORTED)
+ case jsObject: JsObject =>
+ val unsupported: collection.Set[String] = jsObject.keys.diff(MailboxFilter.SUPPORTED)
if (unsupported.nonEmpty) {
JsError(s"These '${unsupported.mkString("[", ", ", "]")}' was unsupported filter options")
} else {
- Json.reads[MailboxFilter].reads(JsObject(underlying))
+ Json.reads[MailboxFilter].reads(jsObject)
}
- }
case jsValue: JsValue => Json.reads[MailboxFilter].reads(jsValue)
}
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org