From a58a67a0912bfb01b6f82958cfb10721585a9325 Mon Sep 17 00:00:00 2001 From: Jem Mawson Date: Wed, 5 Sep 2018 17:31:27 +1000 Subject: [PATCH] remove infix notation in settings impls --- .../caching/scaladsl/CachingSettings.scala | 10 ++--- .../ClientConnectionSettingsImpl.scala | 6 +-- .../settings/ConnectionPoolSettingsImpl.scala | 16 ++++---- .../settings/HttpsProxySettingsImpl.scala | 6 +-- .../impl/settings/ParserSettingsImpl.scala | 41 ++++++++++--------- .../settings/PreviewServerSettingsImpl.scala | 2 +- .../impl/settings/RoutingSettingsImpl.scala | 17 ++++---- .../ServerSentEventSettingsImpl.scala | 4 +- .../impl/settings/ServerSettingsImpl.scala | 32 +++++++-------- .../settings/Http2ServerSettings.scala | 8 ++-- 10 files changed, 72 insertions(+), 70 deletions(-) diff --git a/akka-http-caching/src/main/scala/akka/http/caching/scaladsl/CachingSettings.scala b/akka-http-caching/src/main/scala/akka/http/caching/scaladsl/CachingSettings.scala index 888ba956cf1..45754bf9055 100644 --- a/akka-http-caching/src/main/scala/akka/http/caching/scaladsl/CachingSettings.scala +++ b/akka-http-caching/src/main/scala/akka/http/caching/scaladsl/CachingSettings.scala @@ -63,14 +63,14 @@ private[http] final case class LfuCacheSettingsImpl( } object CachingSettings extends SettingsCompanion[CachingSettings]("akka.http.caching") { - def fromSubConfig(root: Config, c: Config) = { + def fromSubConfig(root: Config, c: Config): CachingSettingsImpl = { val lfuConfig = c.getConfig("lfu-cache") CachingSettingsImpl( LfuCacheSettingsImpl( - lfuConfig getInt "max-capacity", - lfuConfig getInt "initial-capacity", - lfuConfig getPotentiallyInfiniteDuration "time-to-live", - lfuConfig getPotentiallyInfiniteDuration "time-to-idle" + lfuConfig.getInt("max-capacity"), + lfuConfig.getInt("initial-capacity"), + lfuConfig.getPotentiallyInfiniteDuration("time-to-live"), + lfuConfig.getPotentiallyInfiniteDuration("time-to-idle") ) ) } diff --git a/akka-http-core/src/main/scala/akka/http/impl/settings/ClientConnectionSettingsImpl.scala b/akka-http-core/src/main/scala/akka/http/impl/settings/ClientConnectionSettingsImpl.scala index d9d9b32b468..a0898fbc8b3 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/settings/ClientConnectionSettingsImpl.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/settings/ClientConnectionSettingsImpl.scala @@ -49,9 +49,9 @@ private[akka] object ClientConnectionSettingsImpl extends SettingsCompanion[Clie val c = inner.withFallback(root.getConfig(prefix)) new ClientConnectionSettingsImpl( userAgentHeader = c.getString("user-agent-header").toOption.map(`User-Agent`(_)), - connectingTimeout = c getFiniteDuration "connecting-timeout", - idleTimeout = c getPotentiallyInfiniteDuration "idle-timeout", - requestHeaderSizeHint = c getIntBytes "request-header-size-hint", + connectingTimeout = c.getFiniteDuration("connecting-timeout"), + idleTimeout = c.getPotentiallyInfiniteDuration("idle-timeout"), + requestHeaderSizeHint = c.getIntBytes("request-header-size-hint"), logUnencryptedNetworkBytes = LogUnencryptedNetworkBytes(c getString "log-unencrypted-network-bytes"), websocketSettings = WebSocketSettingsImpl.client(c.getConfig("websocket")), socketOptions = SocketOptionSettings.fromSubConfig(root, c.getConfig("socket-options")), diff --git a/akka-http-core/src/main/scala/akka/http/impl/settings/ConnectionPoolSettingsImpl.scala b/akka-http-core/src/main/scala/akka/http/impl/settings/ConnectionPoolSettingsImpl.scala index b3bc9766011..d371f020577 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/settings/ConnectionPoolSettingsImpl.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/settings/ConnectionPoolSettingsImpl.scala @@ -50,20 +50,20 @@ private[akka] final case class ConnectionPoolSettingsImpl( } object ConnectionPoolSettingsImpl extends SettingsCompanion[ConnectionPoolSettingsImpl]("akka.http.host-connection-pool") { - def fromSubConfig(root: Config, c: Config) = { + def fromSubConfig(root: Config, c: Config): ConnectionPoolSettingsImpl = { new ConnectionPoolSettingsImpl( - c getInt "max-connections", - c getInt "min-connections", - c getInt "max-retries", - c getInt "max-open-requests", - c getInt "pipelining-limit", - c getPotentiallyInfiniteDuration "idle-timeout", + c.getInt("max-connections"), + c.getInt("min-connections"), + c.getInt("max-retries"), + c.getInt("max-open-requests"), + c.getInt("pipelining-limit"), + c.getPotentiallyInfiniteDuration("idle-timeout"), ClientConnectionSettingsImpl.fromSubConfig(root, c.getConfig("client")), c.getString("pool-implementation").toLowerCase match { case "legacy" ⇒ PoolImplementation.Legacy case "new" ⇒ PoolImplementation.New }, - c getPotentiallyInfiniteDuration "response-entity-subscription-timeout" + c.getPotentiallyInfiniteDuration("response-entity-subscription-timeout") ) } } diff --git a/akka-http-core/src/main/scala/akka/http/impl/settings/HttpsProxySettingsImpl.scala b/akka-http-core/src/main/scala/akka/http/impl/settings/HttpsProxySettingsImpl.scala index 9b46f19117f..8d88a2b1ae7 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/settings/HttpsProxySettingsImpl.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/settings/HttpsProxySettingsImpl.scala @@ -21,10 +21,10 @@ private[http] final case class HttpsProxySettingsImpl( } object HttpsProxySettingsImpl extends SettingsCompanion[HttpsProxySettingsImpl]("akka.http.client.proxy.https") { - override def fromSubConfig(root: Config, c: Config) = { + override def fromSubConfig(root: Config, c: Config): HttpsProxySettingsImpl = { new HttpsProxySettingsImpl( - c getString "host", - c getInt "port" + c.getString("host"), + c.getInt("port") ) } } diff --git a/akka-http-core/src/main/scala/akka/http/impl/settings/ParserSettingsImpl.scala b/akka-http-core/src/main/scala/akka/http/impl/settings/ParserSettingsImpl.scala index 082a3dabde1..5f6a07b076c 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/settings/ParserSettingsImpl.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/settings/ParserSettingsImpl.scala @@ -64,33 +64,34 @@ object ParserSettingsImpl extends SettingsCompanion[ParserSettingsImpl]("akka.ht private[this] val noCustomStatusCodes: Int ⇒ Option[StatusCode] = ConstantFun.scalaAnyToNone private[ParserSettingsImpl] val noCustomMediaTypes: (String, String) ⇒ Option[MediaType] = ConstantFun.scalaAnyTwoToNone - def fromSubConfig(root: Config, inner: Config) = { + def fromSubConfig(root: Config, inner: Config): ParserSettingsImpl = { val c = inner.withFallback(root.getConfig(prefix)) val cacheConfig = c getConfig "header-cache" new ParserSettingsImpl( - c getIntBytes "max-uri-length", - c getIntBytes "max-method-length", - c getIntBytes "max-response-reason-length", - c getIntBytes "max-header-name-length", - c getIntBytes "max-header-value-length", - c getIntBytes "max-header-count", - c getPossiblyInfiniteBytes "max-content-length", - c getPossiblyInfiniteBytes "max-to-strict-bytes", - c getIntBytes "max-chunk-ext-length", - c getIntBytes "max-chunk-size", - Uri.ParsingMode(c getString "uri-parsing-mode"), - CookieParsingMode(c getString "cookie-parsing-mode"), - c getBoolean "illegal-header-warnings", - (c getStringList "ignore-illegal-header-for").asScala.map(_.toLowerCase).toSet, - ErrorLoggingVerbosity(c getString "error-logging-verbosity"), - IllegalResponseHeaderValueProcessingMode(c getString "illegal-response-header-value-processing-mode"), + c.getIntBytes("max-uri-length"), + c.getIntBytes("max-method-length"), + c.getIntBytes("max-response-reason-length"), + c.getIntBytes("max-header-name-length"), + c.getIntBytes("max-header-value-length"), + c.getIntBytes("max-header-count"), + c.getPossiblyInfiniteBytes("max-content-length"), + c.getPossiblyInfiniteBytes("max-to-strict-bytes"), + c.getIntBytes("max-chunk-ext-length"), + c.getIntBytes("max-chunk-size"), + Uri.ParsingMode(c.getString("uri-parsing-mode")), + CookieParsingMode(c.getString("cookie-parsing-mode")), + c.getBoolean("illegal-header-warnings"), + c.getStringList("ignore-illegal-header-for").asScala.map(_.toLowerCase).toSet, + ErrorLoggingVerbosity(c.getString("error-logging-verbosity")), + IllegalResponseHeaderValueProcessingMode(c.getString("illegal-response-header-value-processing-mode")), cacheConfig.entrySet.asScala.map(kvp ⇒ kvp.getKey → cacheConfig.getInt(kvp.getKey))(collection.breakOut), - c getBoolean "tls-session-info-header", - c getBoolean "modeled-header-parsing", + c.getBoolean("tls-session-info-header"), + c.getBoolean("modeled-header-parsing"), noCustomMethods, noCustomStatusCodes, - noCustomMediaTypes) + noCustomMediaTypes + ) } } diff --git a/akka-http-core/src/main/scala/akka/http/impl/settings/PreviewServerSettingsImpl.scala b/akka-http-core/src/main/scala/akka/http/impl/settings/PreviewServerSettingsImpl.scala index e360e862d85..59a3927b74e 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/settings/PreviewServerSettingsImpl.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/settings/PreviewServerSettingsImpl.scala @@ -18,6 +18,6 @@ private[http] final case class PreviewServerSettingsImpl( object PreviewServerSettingsImpl extends SettingsCompanion[PreviewServerSettingsImpl]("akka.http.server.preview") { def fromSubConfig(root: Config, c: Config) = PreviewServerSettingsImpl( - c getBoolean "enable-http2" + c.getBoolean("enable-http2") ) } diff --git a/akka-http-core/src/main/scala/akka/http/impl/settings/RoutingSettingsImpl.scala b/akka-http-core/src/main/scala/akka/http/impl/settings/RoutingSettingsImpl.scala index 00f080e4321..8eba9de5483 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/settings/RoutingSettingsImpl.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/settings/RoutingSettingsImpl.scala @@ -25,12 +25,13 @@ private[http] final case class RoutingSettingsImpl( object RoutingSettingsImpl extends SettingsCompanion[RoutingSettingsImpl]("akka.http.routing") { def fromSubConfig(root: Config, c: Config) = new RoutingSettingsImpl( - c getBoolean "verbose-error-messages", - c getBoolean "file-get-conditional", - c getBoolean "render-vanity-footer", - c getInt "range-count-limit", - c getBytes "range-coalescing-threshold", - c getIntBytes "decode-max-bytes-per-chunk", - c getPossiblyInfiniteBytes "decode-max-size", - c getString "file-io-dispatcher") + c.getBoolean("verbose-error-messages"), + c.getBoolean("file-get-conditional"), + c.getBoolean("render-vanity-footer"), + c.getInt("range-count-limit"), + c.getBytes("range-coalescing-threshold"), + c.getIntBytes("decode-max-bytes-per-chunk"), + c.getPossiblyInfiniteBytes("decode-max-size"), + c.getString("file-io-dispatcher") + ) } diff --git a/akka-http-core/src/main/scala/akka/http/impl/settings/ServerSentEventSettingsImpl.scala b/akka-http-core/src/main/scala/akka/http/impl/settings/ServerSentEventSettingsImpl.scala index ddfd8f7683c..ab7d25af7a5 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/settings/ServerSentEventSettingsImpl.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/settings/ServerSentEventSettingsImpl.scala @@ -22,7 +22,7 @@ private[http] final case class ServerSentEventSettingsImpl( object ServerSentEventSettingsImpl extends SettingsCompanion[ServerSentEventSettingsImpl]("akka.http.sse") { def fromSubConfig(root: Config, c: Config) = ServerSentEventSettingsImpl( - c getInt "max-event-size", - c getInt "max-line-size" + c.getInt("max-event-size"), + c.getInt("max-line-size") ) } diff --git a/akka-http-core/src/main/scala/akka/http/impl/settings/ServerSettingsImpl.scala b/akka-http-core/src/main/scala/akka/http/impl/settings/ServerSettingsImpl.scala index 505e1cc7511..f86611879a6 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/settings/ServerSettingsImpl.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/settings/ServerSettingsImpl.scala @@ -76,22 +76,22 @@ private[http] object ServerSettingsImpl extends SettingsCompanion[ServerSettings c.getString("server-header").toOption.map(Server(_)), PreviewServerSettingsImpl.fromSubConfig(root, c.getConfig("preview")), Timeouts( - c getPotentiallyInfiniteDuration "idle-timeout", - c getPotentiallyInfiniteDuration "request-timeout", - c getFiniteDuration "bind-timeout", - c getPotentiallyInfiniteDuration "linger-timeout"), - c getInt "max-connections", - c getInt "pipelining-limit", - c getBoolean "remote-address-header", - c getBoolean "raw-request-uri-header", - c getBoolean "transparent-head-requests", - c getBoolean "verbose-error-messages", - c getIntBytes "response-header-size-hint", - c getInt "backlog", - LogUnencryptedNetworkBytes(c getString "log-unencrypted-network-bytes"), + c.getPotentiallyInfiniteDuration("idle-timeout"), + c.getPotentiallyInfiniteDuration("request-timeout"), + c.getFiniteDuration("bind-timeout"), + c.getPotentiallyInfiniteDuration("linger-timeout")), + c.getInt("max-connections"), + c.getInt("pipelining-limit"), + c.getBoolean("remote-address-header"), + c.getBoolean("raw-request-uri-header"), + c.getBoolean("transparent-head-requests"), + c.getBoolean("verbose-error-messages"), + c.getIntBytes("response-header-size-hint"), + c.getInt("backlog"), + LogUnencryptedNetworkBytes(c.getString("log-unencrypted-network-bytes")), SocketOptionSettings.fromSubConfig(root, c.getConfig("socket-options")), defaultHostHeader = - HttpHeader.parse("Host", c getString "default-host-header", ParserSettings(root)) match { + HttpHeader.parse("Host", c.getString("default-host-header"), ParserSettings(root)) match { case HttpHeader.ParsingResult.Ok(x: Host, Nil) ⇒ x case result ⇒ val info = result.errors.head.withSummary("Configured `default-host-header` is illegal") @@ -100,8 +100,8 @@ private[http] object ServerSettingsImpl extends SettingsCompanion[ServerSettings WebSocketSettingsImpl.server(c.getConfig("websocket")), ParserSettingsImpl.fromSubConfig(root, c.getConfig("parsing")), Http2ServerSettings.Http2ServerSettingsImpl.fromSubConfig(root, c.getConfig("http2")), - c getInt "default-http-port", - c getInt "default-https-port", + c.getInt("default-http-port"), + c.getInt("default-https-port"), terminationDeadlineExceededResponseFrom(c) ) diff --git a/akka-http-core/src/main/scala/akka/http/scaladsl/settings/Http2ServerSettings.scala b/akka-http-core/src/main/scala/akka/http/scaladsl/settings/Http2ServerSettings.scala index 0d26f046881..80915df026e 100644 --- a/akka-http-core/src/main/scala/akka/http/scaladsl/settings/Http2ServerSettings.scala +++ b/akka-http-core/src/main/scala/akka/http/scaladsl/settings/Http2ServerSettings.scala @@ -58,10 +58,10 @@ object Http2ServerSettings extends SettingsCompanion[Http2ServerSettings] { private[http] object Http2ServerSettingsImpl extends akka.http.impl.util.SettingsCompanion[Http2ServerSettingsImpl]("akka.http.server.http2") { def fromSubConfig(root: Config, c: Config): Http2ServerSettingsImpl = Http2ServerSettingsImpl( - maxConcurrentStreams = c getInt "max-concurrent-streams", - requestEntityChunkSize = c getIntBytes "request-entity-chunk-size", - incomingConnectionLevelBufferSize = c getIntBytes "incoming-connection-level-buffer-size", - incomingStreamLevelBufferSize = c getIntBytes "incoming-stream-level-buffer-size", + maxConcurrentStreams = c.getInt("max-concurrent-streams"), + requestEntityChunkSize = c.getIntBytes("request-entity-chunk-size"), + incomingConnectionLevelBufferSize = c.getIntBytes("incoming-connection-level-buffer-size"), + incomingStreamLevelBufferSize = c.getIntBytes("incoming-stream-level-buffer-size"), None // no possibility to configure internal settings with config ) }