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 2021/11/03 02:28:43 UTC

[james-project] branch master updated: JAMES-3539 JmapRfc8621Configuration: avoid implicit Integer => Int conversion (#732)

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


The following commit(s) were added to refs/heads/master by this push:
     new f1ab367  JAMES-3539 JmapRfc8621Configuration: avoid implicit Integer => Int conversion (#732)
f1ab367 is described below

commit f1ab367137f1f55f9606b9ca8ec215a7bdbb9bb9
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Wed Nov 3 09:28:04 2021 +0700

    JAMES-3539 JmapRfc8621Configuration: avoid implicit Integer => Int conversion (#732)
    
    https://stackoverflow.com/questions/60600502/scala-optionnull-expected-as-none-but-i-got-some0
    
    We got Some(0) instead of None
---
 .../org/apache/james/jmap/core/JmapRfc8621Configuration.scala | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/JmapRfc8621Configuration.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/JmapRfc8621Configuration.scala
index cd998ab..9d925ce 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/JmapRfc8621Configuration.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/JmapRfc8621Configuration.scala
@@ -20,12 +20,15 @@
 package org.apache.james.jmap.core
 
 import java.net.{URI, URL}
+import java.util.Optional
 
 import org.apache.commons.configuration2.Configuration
 import org.apache.james.jmap.core.JmapRfc8621Configuration.UPLOAD_LIMIT_30_MB
 import org.apache.james.jmap.pushsubscription.PushClientConfiguration
 import org.apache.james.util.Size
 
+import scala.jdk.OptionConverters._
+
 object JmapRfc8621Configuration {
   val LOCALHOST_URL_PREFIX: String = "http://localhost"
   val LOCALHOST_WEBSOCKET_URL_PREFIX: String = "ws://localhost"
@@ -43,8 +46,8 @@ object JmapRfc8621Configuration {
         .map(Size.parse)
         .map(MaxSizeUpload.of(_).get)
         .getOrElse(UPLOAD_LIMIT_30_MB),
-      maxTimeoutSeconds = Option(configuration.getInteger("webpush.maxTimeoutSeconds", null)),
-      maxConnections = Option(configuration.getInteger("webpush.maxConnections", null)))
+      maxTimeoutSeconds = Optional.ofNullable(configuration.getInteger("webpush.maxTimeoutSeconds", null)).map(Integer2int).toScala,
+      maxConnections = Optional.ofNullable(configuration.getInteger("webpush.maxConnections", null)).map(Integer2int).toScala)
   }
 }
 
@@ -59,5 +62,7 @@ case class JmapRfc8621Configuration(urlPrefixString: String, websocketPrefixStri
   val eventSourceUrl: URL = new URL(s"$urlPrefixString/eventSource?types={types}&closeAfter={closeafter}&ping={ping}")
   val webSocketUrl: URI = new URI(s"$websocketPrefixString/jmap/ws")
 
-  val webPushConfiguration: PushClientConfiguration = PushClientConfiguration(maxTimeoutSeconds, maxTimeoutSeconds)
+  val webPushConfiguration: PushClientConfiguration = PushClientConfiguration(
+    maxTimeoutSeconds = maxTimeoutSeconds,
+    maxConnections = maxConnections)
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org