From 77cdbbe95a4586b9ba97eff4cb243a65761c852c Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 13 Jan 2026 21:12:49 +0000 Subject: [PATCH 1/3] Update scalafmt-core to 3.10.3 --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 216c2a190..e4a8ff530 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = 3.7.17 +version = 3.10.3 runner.dialect = scala213 project.git = true style = defaultWithAlign From 245df4a95b09802b6c1ea2dbc429259b368bd0ef Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 13 Jan 2026 21:13:28 +0000 Subject: [PATCH 2/3] Reformat with scalafmt 3.10.3 Executed command: scalafmt --non-interactive --- .../http/scaladsl/HttpClientExampleSpec.scala | 4 +- .../BasicDirectivesExamplesSpec.scala | 2 +- .../MarshallingDirectivesExamplesSpec.scala | 6 +-- .../SecurityDirectivesExamplesSpec.scala | 38 +++++++++---------- .../WebSocketDirectivesExamplesSpec.scala | 2 +- .../server/directives/CachingDirectives.scala | 3 +- .../engine/client/HttpsProxyGraphStage.scala | 2 +- .../client/pool/NewHostConnectionPool.scala | 2 +- .../http/impl/engine/http2/FrameLogger.scala | 4 +- .../http/impl/engine/http2/Http2Demux.scala | 2 +- .../engine/http2/Http2StreamHandling.scala | 8 ++-- .../impl/engine/parsing/BodyPartParser.scala | 2 +- .../engine/parsing/HttpHeaderParser.scala | 20 +++++----- .../engine/parsing/HttpMessageParser.scala | 8 ++-- .../engine/parsing/HttpRequestParser.scala | 10 ++--- .../engine/parsing/HttpResponseParser.scala | 6 +-- .../http/impl/engine/parsing/package.scala | 2 +- .../HttpRequestRendererFactory.scala | 4 +- .../engine/server/HttpServerBluePrint.scala | 4 +- .../http/impl/engine/ws/FrameHandler.scala | 6 +-- .../http/impl/engine/ws/FrameLogger.scala | 2 +- .../http/impl/engine/ws/FrameOutHandler.scala | 4 +- .../pekko/http/impl/engine/ws/Handshake.scala | 2 +- .../pekko/http/impl/engine/ws/WebSocket.scala | 4 +- .../engine/ws/WebSocketClientBlueprint.scala | 4 +- .../http/impl/model/parser/CommonRules.scala | 2 +- .../http/impl/model/parser/HeaderParser.scala | 2 +- .../http/impl/model/parser/LinkHeader.scala | 14 +++---- .../impl/settings/ServerSettingsImpl.scala | 2 +- .../pekko/http/impl/util/StreamUtils.scala | 8 ++-- .../apache/pekko/http/impl/util/package.scala | 2 +- .../org/apache/pekko/http/javadsl/Http.scala | 6 ++- .../http/scaladsl/ConnectionContext.scala | 2 +- .../org/apache/pekko/http/scaladsl/Http.scala | 2 +- .../http/scaladsl/model/HttpHeader.scala | 2 +- .../http/scaladsl/model/HttpMessage.scala | 2 +- .../pekko/http/scaladsl/model/Multipart.scala | 2 +- .../pekko/http/scaladsl/model/Uri.scala | 12 +++--- .../http/scaladsl/model/headers/headers.scala | 2 +- .../http/scaladsl/model/ws/Message.scala | 4 +- .../scaladsl/settings/ParserSettings.scala | 6 +-- .../pekko/http/scaladsl/util/FastFuture.scala | 2 +- .../client/HttpsProxyGraphStageSpec.scala | 2 +- .../engine/parsing/HttpHeaderParserSpec.scala | 3 +- .../rendering/ResponseRendererSpec.scala | 2 +- .../server/HttpServerTestSetupBase.scala | 2 +- .../http/impl/engine/ws/BitBuilder.scala | 2 +- .../impl/engine/ws/WSClientAutobahnTest.scala | 2 +- .../scaladsl/GracefulTerminationSpec.scala | 2 +- .../pekko/http/scaladsl/TestServer.scala | 4 +- .../org/apache/pekko/testkit/PekkoSpec.scala | 2 +- .../pekko/http/cors/CorsDirectivesSpec.scala | 6 +-- .../http/fix/MigrateToServerBuilder.scala | 2 +- .../javadsl/testkit/TestRouteResult.scala | 2 +- .../remote/testkit/MultiNodeConfig.scala | 4 +- ...ardEntityDefaultExceptionHandlerSpec.scala | 4 +- .../CacheConditionDirectivesSpec.scala | 2 +- .../FileAndResourceDirectivesSpec.scala | 4 +- .../directives/FormFieldDirectivesSpec.scala | 2 +- .../directives/FutureDirectivesSpec.scala | 6 +-- .../MarshallingDirectivesSpec.scala | 4 +- .../directives/ParameterDirectivesSpec.scala | 6 +-- .../directives/PathDirectivesSpec.scala | 6 +-- .../directives/RouteDirectivesSpec.scala | 2 +- .../directives/WebSocketDirectivesSpec.scala | 2 +- .../directives/DebuggingDirectives.scala | 2 +- .../server/directives/HeaderDirectives.scala | 2 +- .../scaladsl/client/RequestBuilding.scala | 2 +- .../http/scaladsl/common/StrictForm.scala | 5 ++- .../scaladsl/server/RejectionHandler.scala | 2 +- .../pekko/http/scaladsl/server/Route.scala | 3 +- .../scaladsl/server/RouteConcatenation.scala | 2 +- .../server/directives/CodingDirectives.scala | 2 +- .../FileAndResourceDirectives.scala | 6 +-- .../directives/FormFieldDirectives.scala | 6 +-- .../directives/MarshallingDirectives.scala | 8 ++-- .../directives/ParameterDirectives.scala | 2 +- .../server/directives/RangeDirectives.scala | 2 +- .../directives/SecurityDirectives.scala | 2 +- .../server/directives/TimeoutDirectives.scala | 2 +- .../settings/OversizedSseStrategy.scala | 2 +- .../MultipartUnmarshallers.scala | 2 +- .../engine/http2/H2SpecIntegrationSpec.scala | 11 +++--- .../engine/http2/Http2FrameHpackSupport.scala | 2 +- .../pekko/http/scaladsl/Http2ServerTest.scala | 6 +-- project/ValidatePullRequest.scala | 4 +- 86 files changed, 191 insertions(+), 180 deletions(-) diff --git a/docs/src/test/scala/docs/http/scaladsl/HttpClientExampleSpec.scala b/docs/src/test/scala/docs/http/scaladsl/HttpClientExampleSpec.scala index ad1fc403b..3ff81662f 100644 --- a/docs/src/test/scala/docs/http/scaladsl/HttpClientExampleSpec.scala +++ b/docs/src/test/scala/docs/http/scaladsl/HttpClientExampleSpec.scala @@ -192,8 +192,8 @@ class HttpClientExampleSpec extends AnyWordSpec with Matchers with CompileOnlySp Source.queue[(HttpRequest, Promise[HttpResponse])](QueueSize) .via(poolClientFlow) .to(Sink.foreach { - case ((Success(resp), p)) => p.success(resp) - case ((Failure(e), p)) => p.failure(e) + case (Success(resp), p) => p.success(resp) + case (Failure(e), p) => p.failure(e) }) .run() diff --git a/docs/src/test/scala/docs/http/scaladsl/server/directives/BasicDirectivesExamplesSpec.scala b/docs/src/test/scala/docs/http/scaladsl/server/directives/BasicDirectivesExamplesSpec.scala index 5e4dbe624..f52aa3eb8 100644 --- a/docs/src/test/scala/docs/http/scaladsl/server/directives/BasicDirectivesExamplesSpec.scala +++ b/docs/src/test/scala/docs/http/scaladsl/server/directives/BasicDirectivesExamplesSpec.scala @@ -273,7 +273,7 @@ class BasicDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec { private def nonSuccessToEmptyJsonEntity(response: HttpResponse): HttpResponse = response.status match { case code if code.isSuccess => response - case code => + case code => log.warning("Dropping response entity since response status code was: {}", code) response.withEntity(NullJsonEntity) } diff --git a/docs/src/test/scala/docs/http/scaladsl/server/directives/MarshallingDirectivesExamplesSpec.scala b/docs/src/test/scala/docs/http/scaladsl/server/directives/MarshallingDirectivesExamplesSpec.scala index b4092bcb2..70a4968ed 100644 --- a/docs/src/test/scala/docs/http/scaladsl/server/directives/MarshallingDirectivesExamplesSpec.scala +++ b/docs/src/test/scala/docs/http/scaladsl/server/directives/MarshallingDirectivesExamplesSpec.scala @@ -46,7 +46,7 @@ class MarshallingDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec // tests: Post("/", HttpEntity(`application/json`, """{ "name": "Jane", "favoriteNumber" : 42 }""")) ~> - route ~> check { + route ~> check { responseAs[String] shouldEqual "Person: Jane - favorite number: 42" } // #example-entity-with-json @@ -66,7 +66,7 @@ class MarshallingDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec // tests: Post("/", HttpEntity(`application/json`, """{ "name": "Jane", "favoriteNumber" : 42 }""")) ~> - route ~> check { + route ~> check { responseAs[String] shouldEqual """Person: "Jane" - favorite number: 42""" } // #example-entity-with-raw-json @@ -115,7 +115,7 @@ class MarshallingDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec // tests: Post("/", HttpEntity(`application/json`, """{ "name": "Jane", "favoriteNumber" : 42 }""")) ~> - route ~> check { + route ~> check { mediaType shouldEqual `application/json` responseAs[String] should include(""""name":"Jane"""") responseAs[String] should include(""""favoriteNumber":42""") diff --git a/docs/src/test/scala/docs/http/scaladsl/server/directives/SecurityDirectivesExamplesSpec.scala b/docs/src/test/scala/docs/http/scaladsl/server/directives/SecurityDirectivesExamplesSpec.scala index 7327f8140..c2dd2c249 100644 --- a/docs/src/test/scala/docs/http/scaladsl/server/directives/SecurityDirectivesExamplesSpec.scala +++ b/docs/src/test/scala/docs/http/scaladsl/server/directives/SecurityDirectivesExamplesSpec.scala @@ -52,14 +52,14 @@ class SecurityDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec { val validCredentials = BasicHttpCredentials("John", "p4ssw0rd") Get("/secured") ~> addCredentials(validCredentials) ~> // adds Authorization header - route ~> check { + route ~> check { responseAs[String] shouldEqual "The user is 'John'" } val invalidCredentials = BasicHttpCredentials("Peter", "pan") - Get("/secured") ~> + Get("/secured") ~> addCredentials(invalidCredentials) ~> // adds Authorization header - route ~> check { + route ~> check { status shouldEqual StatusCodes.Unauthorized responseAs[String] shouldEqual "The supplied authentication is invalid" header[`WWW-Authenticate`].get.challenges.head shouldEqual HttpChallenge("Basic", Some("secure site"), @@ -93,20 +93,20 @@ class SecurityDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec { val validCredentials = BasicHttpCredentials("John", "p4ssw0rd") Get("/secured") ~> addCredentials(validCredentials) ~> // adds Authorization header - route ~> check { + route ~> check { responseAs[String] shouldEqual "The user is 'John'" } val validAdminCredentials = BasicHttpCredentials("John", "p4ssw0rd-special") Get("/secured") ~> addCredentials(validAdminCredentials) ~> // adds Authorization header - route ~> check { + route ~> check { responseAs[String] shouldEqual "The user is 'John-admin'" } val invalidCredentials = BasicHttpCredentials("Peter", "pan") - Get("/secured") ~> + Get("/secured") ~> addCredentials(invalidCredentials) ~> // adds Authorization header - route ~> check { + route ~> check { status shouldEqual StatusCodes.Unauthorized responseAs[String] shouldEqual "The supplied authentication is invalid" header[`WWW-Authenticate`].get.challenges.head shouldEqual HttpChallenge("Basic", Some("secure site"), @@ -146,14 +146,14 @@ class SecurityDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec { val validCredentials = BasicHttpCredentials("John", "p4ssw0rd") Get("/secured") ~> addCredentials(validCredentials) ~> // adds Authorization header - route ~> check { + route ~> check { responseAs[String] shouldEqual "The user is 'John'" } val invalidCredentials = BasicHttpCredentials("Peter", "pan") - Get("/secured") ~> + Get("/secured") ~> addCredentials(invalidCredentials) ~> // adds Authorization header - route ~> check { + route ~> check { status shouldEqual StatusCodes.Unauthorized responseAs[String] shouldEqual "The supplied authentication is invalid" header[`WWW-Authenticate`].get.challenges.head shouldEqual HttpChallenge("Basic", Some("secure site"), @@ -193,14 +193,14 @@ class SecurityDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec { val validCredentials = BasicHttpCredentials("John", "p4ssw0rd") Get("/secured") ~> addCredentials(validCredentials) ~> // adds Authorization header - route ~> check { + route ~> check { responseAs[String] shouldEqual "The user is 'John'" } val invalidCredentials = BasicHttpCredentials("Peter", "pan") - Get("/secured") ~> + Get("/secured") ~> addCredentials(invalidCredentials) ~> // adds Authorization header - route ~> check { + route ~> check { status shouldEqual StatusCodes.Unauthorized responseAs[String] shouldEqual "The supplied authentication is invalid" header[`WWW-Authenticate`].get.challenges.head shouldEqual HttpChallenge("Basic", Some("secure site"), @@ -241,7 +241,7 @@ class SecurityDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec { val validCredentials = BasicHttpCredentials("John", "p4ssw0rd") Get("/secured") ~> addCredentials(validCredentials) ~> // adds Authorization header - route ~> check { + route ~> check { status shouldEqual StatusCodes.OK responseAs[String] shouldEqual "Authenticated!" } @@ -278,14 +278,14 @@ class SecurityDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec { // tests: val johnsCred = BasicHttpCredentials("John", "p4ssw0rd") Get("/peters-lair") ~> addCredentials(johnsCred) ~> // adds Authorization header - route ~> check { + route ~> check { status shouldEqual StatusCodes.Forbidden responseAs[String] shouldEqual "The supplied authentication is not authorized to access this resource" } val petersCred = BasicHttpCredentials("Peter", "pan") Get("/peters-lair") ~> addCredentials(petersCred) ~> // adds Authorization header - route ~> check { + route ~> check { responseAs[String] shouldEqual "'Peter' visited Peter's lair" } // #authorize0-0 @@ -322,14 +322,14 @@ class SecurityDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec { // tests: val johnsCred = BasicHttpCredentials("John", "p4ssw0rd") Get("/peters-lair") ~> addCredentials(johnsCred) ~> // adds Authorization header - route ~> check { + route ~> check { status shouldEqual StatusCodes.Forbidden responseAs[String] shouldEqual "The supplied authentication is not authorized to access this resource" } val petersCred = BasicHttpCredentials("Peter", "pan") Get("/peters-lair") ~> addCredentials(petersCred) ~> // adds Authorization header - route ~> check { + route ~> check { responseAs[String] shouldEqual "'Peter' visited Peter's lair" } // #authorizeAsync0 @@ -350,7 +350,7 @@ class SecurityDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec { // tests: val johnsCred = BasicHttpCredentials("John", "p4ssw0rd") Get("/") ~> addCredentials(johnsCred) ~> // adds Authorization header - route ~> check { + route ~> check { responseAs[String] shouldEqual "Credentials: Basic Sm9objpwNHNzdzByZA==" } diff --git a/docs/src/test/scala/docs/http/scaladsl/server/directives/WebSocketDirectivesExamplesSpec.scala b/docs/src/test/scala/docs/http/scaladsl/server/directives/WebSocketDirectivesExamplesSpec.scala index 706b880d5..3c5dcc317 100644 --- a/docs/src/test/scala/docs/http/scaladsl/server/directives/WebSocketDirectivesExamplesSpec.scala +++ b/docs/src/test/scala/docs/http/scaladsl/server/directives/WebSocketDirectivesExamplesSpec.scala @@ -94,7 +94,7 @@ class WebSocketDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec { // WS creates a WebSocket request for testing WS("/services", wsClient.flow, List("other", "echo")) ~> - websocketMultipleProtocolRoute ~> + websocketMultipleProtocolRoute ~> check { expectWebSocketUpgradeWithProtocol { protocol => protocol shouldEqual "echo" diff --git a/http-caching/src/main/scala/org/apache/pekko/http/javadsl/server/directives/CachingDirectives.scala b/http-caching/src/main/scala/org/apache/pekko/http/javadsl/server/directives/CachingDirectives.scala index 0381557ed..6c3a376f7 100644 --- a/http-caching/src/main/scala/org/apache/pekko/http/javadsl/server/directives/CachingDirectives.scala +++ b/http-caching/src/main/scala/org/apache/pekko/http/javadsl/server/directives/CachingDirectives.scala @@ -27,7 +27,8 @@ object CachingDirectives { import pekko.http.scaladsl.server.directives.{ CachingDirectives => D } - private implicit def routeResultCacheMapping[K]: JavaMapping[Cache[K, RouteResult], pekko.http.caching.scaladsl.Cache[ + private implicit def routeResultCacheMapping[K]: JavaMapping[Cache[K, RouteResult], + pekko.http.caching.scaladsl.Cache[ K, pekko.http.scaladsl.server.RouteResult]] = CacheJavaMapping.cacheMapping[K, RouteResult, K, pekko.http.scaladsl.server.RouteResult] diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/HttpsProxyGraphStage.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/HttpsProxyGraphStage.scala index 458e5a2c4..cf7694a82 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/HttpsProxyGraphStage.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/HttpsProxyGraphStage.scala @@ -141,7 +141,7 @@ private final class HttpsProxyGraphStage( s"parseResult should be MessageEnd but was $parseResult") parser.onPull() match { // NeedMoreData is what we emit in overridden `parseMessage` in case input.size == offset - case NeedMoreData => + case NeedMoreData => case RemainingBytes(bytes) => push(sslOut, bytes) // parser already read more than expected, forward that data directly pushed = true diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/pool/NewHostConnectionPool.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/pool/NewHostConnectionPool.scala index dcc2dbcee..3b776ea34 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/pool/NewHostConnectionPool.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/pool/NewHostConnectionPool.scala @@ -463,7 +463,7 @@ private[client] object NewHostConnectionPool { val newRequest = request.entity match { case _: HttpEntity.Strict => request - case e => + case e => val (newEntity, entityComplete) = HttpEntity.captureTermination(request.entity) entityComplete.onComplete(safely { case Success(_) => withSlot(_.onRequestEntityCompleted()) diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/FrameLogger.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/FrameLogger.scala index 14c46b4e4..418cb3ac5 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/FrameLogger.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/FrameLogger.scala @@ -65,8 +65,8 @@ private[http2] object FrameLogger { def entryForFrame(frameEvent: FrameEvent): LogEntry = frameEvent match { - case PingFrame(false, data) => LogEntry(0, "PING", hex(data)) - case PingFrame(true, data) => LogEntry(0, "PONG", hex(data)) + case PingFrame(false, data) => LogEntry(0, "PING", hex(data)) + case PingFrame(true, data) => LogEntry(0, "PONG", hex(data)) case HeadersFrame(streamId, endStream, endHeaders, payload, prio) => val prioInfo = if (prio.isDefined) display(entryForFrame(prio.get)) + " " else "" diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2Demux.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2Demux.scala index f05bbb446..2ad364dd3 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2Demux.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2Demux.scala @@ -356,7 +356,7 @@ private[http2] abstract class Http2Demux(http2Settings: Http2CommonSettings, case WindowUpdateFrame(streamId, increment) if streamId == 0 /* else fall through to StreamFrameEvent */ => multiplexer.updateConnectionLevelWindow(increment) - case p: PriorityFrame => multiplexer.updatePriority(p) + case p: PriorityFrame => multiplexer.updatePriority(p) case s: StreamFrameEvent => if (!terminating) handleStreamEvent(s) diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2StreamHandling.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2StreamHandling.scala index bbd1d1540..e4ffb25ac 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2StreamHandling.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2StreamHandling.scala @@ -194,7 +194,9 @@ private[http2] trait Http2StreamHandling extends GraphStageLogic with LogHelper } debug( - s"Incoming side of stream [$streamId] changed state: ${oldState.stateName} -> ${newState.stateName} after handling [$event${if (eventArg ne null) s"($eventArg)" else ""}]") + s"Incoming side of stream [$streamId] changed state: ${oldState.stateName} -> ${newState.stateName} after handling [$event${if (eventArg ne null) + s"($eventArg)" + else ""}]") stateMachineRunning = false if (deferredStreamToEnqueue != -1) { @@ -821,8 +823,8 @@ private[http2] trait Http2StreamHandling extends GraphStageLogic with LogHelper // external callbacks, need to make sure that potential stream state changing events are run through the state machine override def onPush(): Unit = { inlet.grab() match { - case newData: ByteString => buffer ++= newData - case HttpEntity.Chunk(newData, _) => buffer ++= newData + case newData: ByteString => buffer ++= newData + case HttpEntity.Chunk(newData, _) => buffer ++= newData case HttpEntity.LastChunk(_, headers) => if (headers.nonEmpty && !trailer.isEmpty) log.warning( diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/BodyPartParser.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/BodyPartParser.scala index 367ab2c27..327810f56 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/BodyPartParser.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/BodyPartParser.scala @@ -104,7 +104,7 @@ private[http] final class BodyPartParser( @tailrec def loop(): Unit = trampoline match { case null => - case f => + case f => trampoline = null f() loop() diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpHeaderParser.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpHeaderParser.scala index 7b697a440..7bfc0dc25 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpHeaderParser.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpHeaderParser.scala @@ -184,8 +184,8 @@ private[engine] final class HttpHeaderParser private ( @tailrec private def scanHeaderNameAndReturnIndexOfColon(input: ByteString, start: Int, limit: Int)(ix: Int): Int = if (ix < limit) (byteChar(input, ix), settings.illegalResponseHeaderNameProcessingMode) match { - case (':', _) => ix - case (c, _) if tchar(c) => scanHeaderNameAndReturnIndexOfColon(input, start, limit)(ix + 1) + case (':', _) => ix + case (c, _) if tchar(c) => scanHeaderNameAndReturnIndexOfColon(input, start, limit)(ix + 1) case (c, IllegalResponseHeaderNameProcessingMode.Error) => fail(s"Illegal character '${escape(c)}' in header name") case (c, IllegalResponseHeaderNameProcessingMode.Warn) => @@ -206,7 +206,9 @@ private[engine] final class HttpHeaderParser private ( try { insert(input, header)(cursor, endIx, nodeIx, colonIx = 0) values(branch.valueIx) = branch.withValueCountIncreased - } catch { case OutOfTrieSpaceException => /* if we cannot insert then we simply don't */ } + } catch { + case OutOfTrieSpaceException => /* if we cannot insert then we simply don't */ + } resultHeader = header endIx } @@ -215,7 +217,7 @@ private[engine] final class HttpHeaderParser private ( if (char == node) // fast match, descend parseHeaderValue(input, valueStart, branch)(cursor + 1, nodeIx + 1) else node >>> 8 match { - case 0 => parseAndInsertHeader() + case 0 => parseAndInsertHeader() case msb => node & 0xFF match { case 0 => // leaf node resultHeader = values(msb - 1).asInstanceOf[HttpHeader] @@ -223,7 +225,7 @@ private[engine] final class HttpHeaderParser private ( case nodeChar => // branching node val signum = math.signum(char - nodeChar) branchData(rowIx(msb) + 1 + signum) match { - case 0 => parseAndInsertHeader() // header doesn't exist yet + case 0 => parseAndInsertHeader() // header doesn't exist yet case subNodeIx => // descend into branch and advance on char matches (otherwise descend but don't advance) parseHeaderValue(input, valueStart, branch)(cursor + 1 - math.abs(signum), subNodeIx) } @@ -353,7 +355,7 @@ private[engine] final class HttpHeaderParser private ( val node = nodes(nodeIx) val char = escape((node & 0xFF).toChar) node >>> 8 match { - case 0 => recurseAndPrefixLines(nodeIx + 1, " ", char + "-", " ") + case 0 => recurseAndPrefixLines(nodeIx + 1, " ", char + "-", " ") case msb => node & 0xFF match { case 0 => values(msb - 1) match { case ValueBranch(_, valueParser, branchRootNodeIx, _) => @@ -392,7 +394,7 @@ private[engine] final class HttpHeaderParser private ( def build(nodeIx: Int = 0): Map[String, Int] = { val node = nodes(nodeIx) node >>> 8 match { - case 0 => build(nodeIx + 1) + case 0 => build(nodeIx + 1) case msb if (node & 0xFF) == 0 => values(msb - 1) match { case ValueBranch(_, parser, _, count) => Map(parser.headerName -> count) @@ -568,7 +570,7 @@ private[http] object HttpHeaderParser { settings.illegalResponseHeaderValueProcessingMode)() val trimmedHeaderValue = headerValue.trim val header = parser(trimmedHeaderValue) match { - case HeaderParser.Success(h) => h + case HeaderParser.Success(h) => h case HeaderParser.Failure(error) => onIllegalHeader(error.withSummaryPrepended(s"Illegal '$headerName' header").withErrorHeaderName(headerName)) RawHeader(headerName, trimmedHeaderValue) @@ -599,7 +601,7 @@ private[http] object HttpHeaderParser { def appended2(c: Int) = if ((c >> 16) != 0) appended(c.toChar).append((c >> 16).toChar) else appended(c.toChar) if (ix < limit) byteChar(input, ix) match { - case '\t' => scanHeaderValue(hhp, input, start, limit, log, mode)(appended(' '), ix + 1) + case '\t' => scanHeaderValue(hhp, input, start, limit, log, mode)(appended(' '), ix + 1) case '\r' if byteAt(input, ix + 1) == LF_BYTE => if (WSP(byteChar(input, ix + 2))) scanHeaderValue(hhp, input, start, limit, log, mode)(appended(' '), ix + 3) else (if (sb != null) sb.toString else asciiString(input, start, ix), ix + 2) diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpMessageParser.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpMessageParser.scala index d295d9fcd..4a8004079 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpMessageParser.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpMessageParser.scala @@ -101,7 +101,7 @@ private[http] trait HttpMessageParser[Output >: MessageOutput <: ParserOutput] { protected final def doPull(): Output = result match { - case null => if (terminated) StreamEnd else NeedMoreData + case null => if (terminated) StreamEnd else NeedMoreData case buffer: ListBuffer[Output] @unchecked => val head = buffer.head buffer.remove(0) // faster than `ListBuffer::drop` @@ -311,11 +311,11 @@ private[http] trait HttpMessageParser[Output >: MessageOutput <: ParserOutput] { @tailrec def parseSize(cursor: Int, size: Long): StateResult = if (size <= Int.MaxValue) { byteChar(input, cursor) match { - case c if CharacterClasses.HEXDIG(c) => parseSize(cursor + 1, size * 16 + CharUtils.hexValue(c)) + case c if CharacterClasses.HEXDIG(c) => parseSize(cursor + 1, size * 16 + CharUtils.hexValue(c)) case c if size > settings.maxChunkSize => failEntityStream( s"HTTP chunk of $size bytes exceeds the configured limit of ${settings.maxChunkSize} bytes") - case ';' if cursor > offset => parseChunkExtensions(size.toInt, cursor + 1)() + case ';' if cursor > offset => parseChunkExtensions(size.toInt, cursor + 1)() case '\r' if cursor > offset && byteAt(input, cursor + 1) == LF_BYTE => parseChunkBody(size.toInt, "", cursor + 2) case '\n' if cursor > offset => parseChunkBody(size.toInt, "", cursor + 1) @@ -333,7 +333,7 @@ private[http] trait HttpMessageParser[Output >: MessageOutput <: ParserOutput] { protected def emit(output: Output): Unit = result match { case null => result = output case buffer: ListBuffer[Output] @unchecked => buffer += output - case old: Output @unchecked => + case old: Output @unchecked => val buffer = new ListBuffer[Output] buffer += old buffer += output diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpRequestParser.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpRequestParser.scala index 40951e4d4..3df109d91 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpRequestParser.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpRequestParser.scala @@ -142,11 +142,11 @@ private[http] final class HttpRequestParser( case 'A' => parseMethod(PATCH, 2) case _ => parseCustomMethod() } - case 'D' => parseMethod(DELETE) - case 'H' => parseMethod(HEAD) - case 'O' => parseMethod(OPTIONS) - case 'T' => parseMethod(TRACE) - case 'C' => parseMethod(CONNECT) + case 'D' => parseMethod(DELETE) + case 'H' => parseMethod(HEAD) + case 'O' => parseMethod(OPTIONS) + case 'T' => parseMethod(TRACE) + case 'C' => parseMethod(CONNECT) case 0x16 => throw new ParsingException( BadRequest, diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpResponseParser.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpResponseParser.scala index b022dcc4f..8030082d2 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpResponseParser.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpResponseParser.scala @@ -88,10 +88,10 @@ private[http] class HttpResponseParser(protected val settings: ParserSettings, } val code = intValue(0) * 100 + intValue(1) * 10 + intValue(2) statusCode = code match { - case 200 => StatusCodes.OK + case 200 => StatusCodes.OK case code => StatusCodes.getForKey(code) match { case Some(x) => x - case None => customStatusCodes(code).getOrElse { + case None => customStatusCodes(code).getOrElse { // A client must understand the class of any status code, as indicated by the first digit, and // treat an unrecognized status code as being equivalent to the x00 status code of that class // https://tools.ietf.org/html/rfc7231#section-6 @@ -153,7 +153,7 @@ private[http] class HttpResponseParser(protected val settings: ParserSettings, val close = contextForCurrentResponse.get.oneHundredContinueTrigger match { - case None => closeAfterResponseCompletion + case None => closeAfterResponseCompletion case Some(trigger) if statusCode.isSuccess => trigger.trySuccess(()) closeAfterResponseCompletion diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/package.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/package.scala index 53af9461e..bc42944fd 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/package.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/package.scala @@ -51,7 +51,7 @@ package object parsing { settings: ParserSettings.ErrorLoggingVerbosity, ignoreHeaderNames: Set[String] = Set.empty): Unit = settings match { - case ParserSettings.ErrorLoggingVerbosity.Off => // nothing to do + case ParserSettings.ErrorLoggingVerbosity.Off => // nothing to do case ParserSettings.ErrorLoggingVerbosity.Simple => if (!ignoreHeaderNames.contains(info.errorHeaderName)) log.warning(info.summary) diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/rendering/HttpRequestRendererFactory.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/rendering/HttpRequestRendererFactory.scala index e502f66b5..45deb91a3 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/rendering/HttpRequestRendererFactory.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/rendering/HttpRequestRendererFactory.scala @@ -134,7 +134,7 @@ private[http] class HttpRequestRendererFactory( def renderStreamed(body: Source[ByteString, Any]): RequestRenderingOutput = { val headerPart = Source.single(r.get) val stream = ctx.sendEntityTrigger match { - case None => headerPart ++ body + case None => headerPart ++ body case Some(future) => val barrier = Source.future(future).drop(1).asInstanceOf[Source[ByteString, Any]] (headerPart ++ barrier ++ body).recoverWithRetries(-1, @@ -172,7 +172,7 @@ private[http] class HttpRequestRendererFactory( def renderStrict(ctx: RequestRenderingContext): ByteString = render(ctx) match { case RequestRenderingOutput.Strict(bytes) => bytes - case _: RequestRenderingOutput.Streamed => + case _: RequestRenderingOutput.Streamed => throw new IllegalArgumentException( s"Request entity was not Strict but ${ctx.request.entity.getClass.getSimpleName}") } diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/server/HttpServerBluePrint.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/server/HttpServerBluePrint.scala index c0f7f6891..80fc48985 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/server/HttpServerBluePrint.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/server/HttpServerBluePrint.scala @@ -541,7 +541,7 @@ private[http] object HttpServerBluePrint { case EntityStreamSizeException(limit, contentLength) => val summary = contentLength match { case Some(cl) => s"Request Content-Length of $cl bytes exceeds the configured limit of $limit bytes" - case None => + case None => s"Aggregated data length of request entity exceeds the configured limit of $limit bytes" } val info = @@ -692,7 +692,7 @@ private[http] object HttpServerBluePrint { new InHandler { override def onPush(): Unit = grab(fromHttp) match { - case HttpData(b) => push(toNet, b) + case HttpData(b) => push(toNet, b) case SwitchToOtherProtocol(bytes, handlerFlow) => push(toNet, bytes) complete(toHttp) diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/FrameHandler.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/FrameHandler.scala index 4871666ab..9efa38794 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/FrameHandler.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/FrameHandler.scala @@ -109,8 +109,8 @@ private[http] object FrameHandler { def handleRegularFrameStart(start: FrameStart): Unit override def handleFrameStart(start: FrameStart): Unit = start.header match { - case h: FrameHeader if h.mask.isDefined && !server => pushProtocolError() - case h: FrameHeader if h.rsv1 || h.rsv2 || h.rsv3 => pushProtocolError() + case h: FrameHeader if h.mask.isDefined && !server => pushProtocolError() + case h: FrameHeader if h.rsv1 || h.rsv2 || h.rsv3 => pushProtocolError() case FrameHeader(op, _, length, fin, _, _, _) if op.isControl && (length > 125 || !fin) => pushProtocolError() case h: FrameHeader if h.opcode.isControl => @@ -152,7 +152,7 @@ private[http] object FrameHandler { setHandler(in, WaitForPeerTcpClose) push(out, PeerClosed.parse(data)) case Opcode.Other(o) => closeWithCode(Protocol.CloseCodes.ProtocolError, "Unsupported opcode") - case other => failStage( + case other => failStage( new IllegalStateException( s"unexpected message of type [${other.getClass.getName}] when expecting ControlFrame")) } diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/FrameLogger.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/FrameLogger.scala index 546edd945..3eb40cb4e 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/FrameLogger.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/FrameLogger.scala @@ -65,7 +65,7 @@ private[ws] object FrameLogger { case f @ FrameStart(header, data) => displayLogEntry(header.opcode.short, header.length, hex(data), f.lastPart, flag(header.fin, "FIN"), flag(header.rsv1, "RSV1"), flag(header.rsv2, "RSV2"), flag(header.rsv3, "RSV3")) case FrameData(data, lastPart) => displayLogEntry("DATA", 0, hex(data), lastPart) - case FrameError(ex) => + case FrameError(ex) => f"${RED}Error: ${ex.getMessage}$RESET" } } diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/FrameOutHandler.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/FrameOutHandler.scala index 99b8ee0bc..3645afbea 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/FrameOutHandler.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/FrameOutHandler.scala @@ -92,7 +92,7 @@ private[http] class FrameOutHandler(serverSide: Boolean, _closeTimeout: FiniteDu private class WaitingForUserHandlerClosed(closeFrame: FrameStart) extends InHandler { def onPush() = grab(in) match { - case UserHandlerCompleted => sendOutLastFrame() + case UserHandlerCompleted => sendOutLastFrame() case UserHandlerErredOut(e) => log.error(e, s"Websocket handler failed while waiting for handler completion with ${e.getMessage}") sendOutLastFrame() @@ -183,7 +183,7 @@ private[http] class FrameOutHandler(serverSide: Boolean, _closeTimeout: FiniteDu becomeSendOutCloseFrameAndComplete(FrameEvent.closeFrame(Protocol.CloseCodes.ProtocolError)) absorbTermination() case x if x.getCause ne null => onUpstreamFailure(x.getCause) - case _ => + case _ => super.onUpstreamFailure(cause) } } diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/Handshake.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/Handshake.scala index b51076bf8..9e0865cc7 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/Handshake.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/Handshake.scala @@ -171,7 +171,7 @@ private[http] object Handshake { handler: Either[Graph[FlowShape[FrameEvent, FrameEvent], Any], Graph[FlowShape[Message, Message], Any]], subprotocol: Option[String], settings: WebSocketSettings, log: LoggingAdapter): HttpResponse = { val frameHandler = handler match { - case Left(frameHandler) => frameHandler + case Left(frameHandler) => frameHandler case Right(messageHandler) => WebSocket.stack(serverSide = true, settings, log = log).join(messageHandler) } diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/WebSocket.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/WebSocket.scala index 5ac882f0d..709fa94fb 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/WebSocket.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/WebSocket.scala @@ -76,11 +76,11 @@ private[http] object WebSocket { val noCustomData = WebSocketSettingsImpl.hasNoCustomPeriodicKeepAliveData(settings) val mkFrame = settings.periodicKeepAliveMode match { case "ping" if noCustomData => mkDirectAnswerPing // sending Ping should result in a Pong back - case "ping" => + case "ping" => () => DirectAnswer(FrameEvent.fullFrame(Opcode.Ping, None, settings.periodicKeepAliveData(), fin = true)) case "pong" if noCustomData => mkDirectAnswerPong // sending Pong means we do not expect a reply - case "pong" => + case "pong" => () => DirectAnswer(FrameEvent.fullFrame(Opcode.Pong, None, settings.periodicKeepAliveData(), fin = true)) case other => throw new IllegalArgumentException(s"Unsupported periodic-keep-alive-mode. " + diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/WebSocketClientBlueprint.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/WebSocketClientBlueprint.scala index 826121de4..34e34b349 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/WebSocketClientBlueprint.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/WebSocketClientBlueprint.scala @@ -113,7 +113,7 @@ private[http] object WebSocketClientBlueprint { override def onPush(): Unit = { parser.parseBytes(grab(in)) match { - case NeedMoreData => pull(in) + case NeedMoreData => pull(in) case ResponseStart(status, protocol, attributes, headers, entity, close) => val response = new HttpResponse(status, headers, attributes, HttpEntity.Empty, protocol) Handshake.Client.validateResponse(response, subprotocols, key) match { @@ -132,7 +132,7 @@ private[http] object WebSocketClientBlueprint { parser.onPull() match { case NeedMoreData => pull(in) case RemainingBytes(bytes) => push(out, bytes) - case other => + case other => throw new IllegalStateException(s"unexpected element of type ${other.getClass}") } case Left(problem) => diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/CommonRules.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/CommonRules.scala index 9fff67839..3633c2a83 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/CommonRules.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/CommonRules.scala @@ -198,7 +198,7 @@ private[parser] trait CommonRules extends StringBuilding { this: Parser => tokenAndParams match { case ("", Nil) => HttpChallenge(scheme, None) case (token, Nil) => HttpChallenge(scheme, None, Map("" -> token)) - case (_, params) => { + case (_, params) => { val (realms, otherParams) = params.partition(_._1.equalsIgnoreCase("realm")) HttpChallenge(scheme, realms.headOption.map(_._2), TreeMap(otherParams: _*)) } diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/HeaderParser.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/HeaderParser.scala index b770723d6..e82c6aafc 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/HeaderParser.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/HeaderParser.scala @@ -126,7 +126,7 @@ private[http] object HeaderParser { val parser = new HeaderParser(v, settings) dispatch(parser, headerName) match { case r @ Success(_) if parser.cursor == v.length => r - case r @ Success(_) => + case r @ Success(_) => Failure(ErrorInfo( "Header parsing error", s"Rule for $headerName accepted trailing garbage. Is the parser missing a trailing EOI?")) diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/LinkHeader.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/LinkHeader.scala index fded1acc0..fbd95a712 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/LinkHeader.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/LinkHeader.scala @@ -35,13 +35,13 @@ private[parser] trait LinkHeader { this: Parser with CommonRules with CommonActi } def `link-param` = rule( - ws("rel") ~ ws('=') ~ `relation-types` ~> LinkParams.rel.apply _ - | ws("anchor") ~ ws('=') ~ ws('"') ~ UriReference('"') ~ ws('"') ~> LinkParams.anchor.apply _ - | ws("rev") ~ ws('=') ~ `relation-types` ~> LinkParams.rev.apply _ - | ws("hreflang") ~ ws('=') ~ language ~> LinkParams.hreflang.apply _ - | ws("media") ~ ws('=') ~ word ~> LinkParams.media.apply _ - | ws("title") ~ ws('=') ~ word ~> LinkParams.title.apply _ - | ws("title*") ~ ws('=') ~ word ~> LinkParams.`title*`.apply _ // support full `ext-value` notation from http://tools.ietf.org/html/rfc5987#section-3.2.1 + ws("rel") ~ ws('=') ~ `relation-types` ~> LinkParams.rel.apply _ + | ws("anchor") ~ ws('=') ~ ws('"') ~ UriReference('"') ~ ws('"') ~> LinkParams.anchor.apply _ + | ws("rev") ~ ws('=') ~ `relation-types` ~> LinkParams.rev.apply _ + | ws("hreflang") ~ ws('=') ~ language ~> LinkParams.hreflang.apply _ + | ws("media") ~ ws('=') ~ word ~> LinkParams.media.apply _ + | ws("title") ~ ws('=') ~ word ~> LinkParams.title.apply _ + | ws("title*") ~ ws('=') ~ word ~> LinkParams.`title*`.apply _ // support full `ext-value` notation from http://tools.ietf.org/html/rfc5987#section-3.2.1 | (ws("type") ~ ws('=') ~ (ws('"') ~ `link-media-type` ~ ws('"') | `link-media-type`) ~> LinkParams.`type`.apply _)) // TODO: support `link-extension` diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/settings/ServerSettingsImpl.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/settings/ServerSettingsImpl.scala index 8680b62db..c263f1376 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/settings/ServerSettingsImpl.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/settings/ServerSettingsImpl.scala @@ -111,7 +111,7 @@ private[http] object ServerSettingsImpl extends SettingsCompanionImpl[ServerSett defaultHostHeader = HttpHeader.parse("Host", c.getString("default-host-header"), parserSettings) match { case HttpHeader.ParsingResult.Ok(x: Host, Nil) => x - case result => + case result => val info = result.errors.head.withSummary("Configured `default-host-header` is illegal") throw new ConfigurationException(info.formatPretty) }, diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/util/StreamUtils.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/util/StreamUtils.scala index 9b7141dc1..aa6ce6a6c 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/util/StreamUtils.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/util/StreamUtils.scala @@ -87,7 +87,7 @@ private[http] object StreamUtils { materializationPromise.trySuccess(()) killResult.future.value match { case Some(res) => handleKill(res) - case None => + case None => killResult.future.onComplete(killCallback.invoke)(ExecutionContext.parasitic) } } @@ -289,11 +289,11 @@ private[http] object StreamUtils { */ def cancelSource(source: Source[_, _])(implicit materializer: Materializer): Unit = source match { case EmptySource => // nothing to do with empty source - case x => + case x => val mat = GraphInterpreter.currentInterpreterOrNull match { case null if materializer ne null => materializer - case null => throw new IllegalStateException( + case null => throw new IllegalStateException( "Need to pass materializer to cancelSource if not run from GraphInterpreter context.") case x => x.subFusingMaterializer // try to use fuse if already running in interpreter context } @@ -326,7 +326,7 @@ private[http] object StreamUtils { def transformEntityStream[T <: HttpEntity, M](entity: T, streamOp: EntityStreamOp[M]): (T, M) = entity match { - case x: HttpEntity.Strict => x.asInstanceOf[T] -> streamOp.strictM + case x: HttpEntity.Strict => x.asInstanceOf[T] -> streamOp.strictM case x: HttpEntity.Default => val (newData, whenCompleted) = streamOp(x.data) x.copy(data = newData).asInstanceOf[T] -> whenCompleted diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/util/package.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/util/package.scala index 3ffe461bb..191958b66 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/util/package.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/util/package.scala @@ -74,7 +74,7 @@ package object util { def awaitResult(atMost: Duration): T = { Await.ready(future, atMost) future.value.get match { - case Success(t) => t + case Success(t) => t case Failure(ex) => throw new RuntimeException( "Trying to await result of failed Future, see the cause for the original problem.", ex) } diff --git a/http-core/src/main/scala/org/apache/pekko/http/javadsl/Http.scala b/http-core/src/main/scala/org/apache/pekko/http/javadsl/Http.scala index 876579347..5cc5898b8 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/javadsl/Http.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/javadsl/Http.scala @@ -566,12 +566,14 @@ class Http(system: ExtendedActorSystem) extends pekko.actor.Extension { scalaFlow: stream.scaladsl.Flow[(scaladsl.model.HttpRequest, T), (Try[scaladsl.model.HttpResponse], T), Mat]) : Flow[Pair[HttpRequest, T], Pair[Try[HttpResponse], T], Mat] = { implicit def id[X]: JavaMapping[X, X] = JavaMapping.identity[X] - JavaMapping.toJava(scalaFlow)(JavaMapping.flowMapping[Pair[HttpRequest, T], (scaladsl.model.HttpRequest, T), Pair[ + JavaMapping.toJava(scalaFlow)(JavaMapping.flowMapping[Pair[HttpRequest, T], (scaladsl.model.HttpRequest, T), + Pair[ Try[HttpResponse], T], (Try[scaladsl.model.HttpResponse], T), Mat, Mat]) } private def adaptOutgoingFlow[T, Mat]( - scalaFlow: stream.scaladsl.Flow[scaladsl.model.HttpRequest, scaladsl.model.HttpResponse, Future[ + scalaFlow: stream.scaladsl.Flow[scaladsl.model.HttpRequest, scaladsl.model.HttpResponse, + Future[ scaladsl.Http.OutgoingConnection]]): Flow[HttpRequest, HttpResponse, CompletionStage[OutgoingConnection]] = Flow.fromGraph { pekko.stream.scaladsl.Flow[HttpRequest].map(_.asScala) diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/ConnectionContext.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/ConnectionContext.scala index be9b98d98..4f0f844c1 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/ConnectionContext.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/ConnectionContext.scala @@ -42,7 +42,7 @@ object ConnectionContext { @ApiMayChange def httpsServer(createSSLEngine: () => SSLEngine): HttpsConnectionContext = new HttpsConnectionContext({ - case None => createSSLEngine() + case None => createSSLEngine() case Some(_) => throw new IllegalArgumentException("host and port supplied for connection based on server connection context") }: Option[(String, Int)] => SSLEngine) diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/Http.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/Http.scala index 4025265b2..55ffc64f5 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/Http.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/Http.scala @@ -631,7 +631,7 @@ class HttpExt @InternalStableApi /* constructor signature is hardcoded in Teleme val ctx = uri.scheme match { case "ws" => ConnectionContext.noEncryption() case "wss" if connectionContext.isSecure => connectionContext - case "wss" => throw new IllegalArgumentException( + case "wss" => throw new IllegalArgumentException( "Provided connectionContext is not secure, yet request to secure `wss` endpoint detected!") case scheme => throw new IllegalArgumentException(s"Illegal URI scheme '$scheme' in '$uri' for WebSocket request. " + diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpHeader.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpHeader.scala index 0434b557d..b7bed271e 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpHeader.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpHeader.scala @@ -93,7 +93,7 @@ object HttpHeader { case Success(preProcessedValue) => HeaderParser.parseFull(name.toLowerCase, preProcessedValue, settings) match { case HeaderParser.Success(header) => ParsingResult.Ok(header, Nil) - case HeaderParser.Failure(info) => + case HeaderParser.Failure(info) => val errors = info.withSummaryPrepended(s"Illegal HTTP header '$name'") :: Nil ParsingResult.Ok(RawHeader(name, preProcessedValue), errors) case HeaderParser.RuleNotFound => ParsingResult.Ok(RawHeader(name, preProcessedValue), Nil) diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpMessage.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpMessage.scala index 019135276..318991302 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpMessage.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpMessage.scala @@ -466,7 +466,7 @@ object HttpRequest { s"Cannot establish effective URI of request to `$uri`, request has a relative URI and $detail", "consider setting `pekko.http.server.default-host-header`") val Host(hostHeaderHost, hostHeaderPort) = hostHeader match { - case OptionVal.None => if (defaultHostHeader.isEmpty) fail("is missing a `Host` header") else defaultHostHeader + case OptionVal.None => if (defaultHostHeader.isEmpty) fail("is missing a `Host` header") else defaultHostHeader case OptionVal.Some(x) if x.isEmpty => if (defaultHostHeader.isEmpty) fail("an empty `Host` header") else defaultHostHeader case OptionVal.Some(x) => x diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/Multipart.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/Multipart.scala index 2533ef633..949af1e82 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/Multipart.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/Multipart.scala @@ -296,7 +296,7 @@ object Multipart { val params = dispositionParams params.get("name") match { case Some(name) => Success(f(name, params - "name", headers.filterNot(_.is("content-disposition")))) - case None => Failure(IllegalHeaderException( + case None => Failure(IllegalHeaderException( "multipart/form-data part must contain `Content-Disposition` header with `name` parameter")) } } diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/Uri.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/Uri.scala index d647a67e0..09d7df932 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/Uri.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/Uri.scala @@ -478,7 +478,7 @@ object Uri { def apply(address: InetAddress): Host = address match { case ipv4: Inet4Address => apply(ipv4) case ipv6: Inet6Address => apply(ipv6) - case _ => + case _ => throw new IllegalArgumentException(s"Unexpected address type(${address.getClass.getSimpleName}): $address") } def apply(address: Inet4Address): IPv4Host = IPv4Host(address.getAddress, address.getHostAddress) @@ -904,7 +904,7 @@ object Uri { case Path.Empty => output.reverse case Segment("." | "..", Slash(tail)) => process(tail, output) case Slash(Segment(".", tail)) => process(if (tail.isEmpty) Path./ else tail, output) - case Slash(Segment("..", tail)) => process( + case Slash(Segment("..", tail)) => process( input = if (tail.isEmpty) Path./ else tail, output = if (output.startsWithSegment) @@ -1024,8 +1024,8 @@ object UriRendering { def renderPath[R <: Rendering]( r: R, path: Path, charset: Charset, encodeFirstSegmentColons: Boolean = false): r.type = path match { - case Path.Empty => r - case Path.Slash(tail) => renderPath(r ~~ '/', tail, charset, false) + case Path.Empty => r + case Path.Slash(tail) => renderPath(r ~~ '/', tail, charset, false) case Path.Segment(head, tail) => val keep = if (encodeFirstSegmentColons) `pchar-base-nc` else `pchar-base` renderPath(encode(r, head, charset, keep), tail, charset, false) @@ -1036,7 +1036,7 @@ object UriRendering { def enc(s: String): Unit = encode(r, s, charset, keep, replaceSpaces = true) @tailrec def append(q: Query): r.type = q match { - case Query.Empty => r + case Query.Empty => r case Query.Cons(key, value, tail) => if (q ne query) r ~~ '&' enc(key) @@ -1058,7 +1058,7 @@ object UriRendering { case c if keep(c) => { r ~~ c; 1 } case ' ' if replaceSpaces => { r ~~ '+'; 1 } case c if c <= 127 && asciiCompatible => { appendEncoded(c.toByte); 1 } - case c => + case c => def append(s: String) = s.getBytes(charset).foreach(appendEncoded) if (Character.isHighSurrogate(c)) { append(new String(Array(string.codePointAt(ix)), 0, 1)); 2 } else { append(c.toString); 1 } diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/headers.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/headers.scala index 6d12daff8..15e6451ff 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/headers.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/headers.scala @@ -116,7 +116,7 @@ abstract class ModeledCustomHeaderCompanion[H <: ModeledCustomHeader[H]] { def apply(value: String): H = parse(value) match { case Success(parsed) => parsed - case Failure(ex) => + case Failure(ex) => throw new IllegalArgumentException(s"Unable to construct custom header by parsing: '$value'", ex) } diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/ws/Message.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/ws/Message.scala index 507f5cf3f..ea35d009c 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/ws/Message.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/ws/Message.scala @@ -48,7 +48,7 @@ sealed trait TextMessage extends pekko.http.javadsl.model.ws.TextMessage with Me */ def toStrict(timeout: FiniteDuration)(implicit fm: Materializer): Future[TextMessage.Strict] = this match { - case TextMessage.Strict(text) => Future.successful(TextMessage.Strict(text)) + case TextMessage.Strict(text) => Future.successful(TextMessage.Strict(text)) case TextMessage.Streamed(textStream) => textStream .completionTimeout(timeout) .runFold(new StringBuilder())((b, s) => b.append(s)) @@ -108,7 +108,7 @@ sealed trait BinaryMessage extends pekko.http.javadsl.model.ws.BinaryMessage wit */ def toStrict(timeout: FiniteDuration)(implicit fm: Materializer): Future[BinaryMessage.Strict] = this match { - case BinaryMessage.Strict(binary) => Future.successful(BinaryMessage.Strict(binary)) + case BinaryMessage.Strict(binary) => Future.successful(BinaryMessage.Strict(binary)) case BinaryMessage.Streamed(binaryStream) => binaryStream .completionTimeout(timeout) .runFold(new ByteStringBuilder())((b, e) => b.append(e)) diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ParserSettings.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ParserSettings.scala index 874027ccd..20833d2dd 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ParserSettings.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ParserSettings.scala @@ -195,7 +195,7 @@ object ParserSettings extends SettingsCompanion[ParserSettings] { case "error" => Error case "warn" => Warn case "ignore" => Ignore - case x => throw new IllegalArgumentException( + case x => throw new IllegalArgumentException( s"[$x] is not a legal `illegal-response-header-value-processing-mode` setting") } } @@ -212,7 +212,7 @@ object ParserSettings extends SettingsCompanion[ParserSettings] { case "error" => Error case "warn" => Warn case "ignore" => Ignore - case x => throw new IllegalArgumentException( + case x => throw new IllegalArgumentException( s"[$x] is not a legal `illegal-response-header-name-processing-mode` setting") } } @@ -231,7 +231,7 @@ object ParserSettings extends SettingsCompanion[ParserSettings] { case "first" => First case "last" => Last case "no-content-type" => NoContentType - case x => throw new IllegalArgumentException( + case x => throw new IllegalArgumentException( s"[$x] is not a legal `conflicting-content-type-header-processing-mode` setting") } } diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/util/FastFuture.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/util/FastFuture.scala index 719924b85..2968b6109 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/util/FastFuture.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/util/FastFuture.scala @@ -52,7 +52,7 @@ class FastFuture[A](val future: Future[A]) extends AnyVal { future match { case FulfilledFuture(a) => strictTransform(a, s) case ErrorFuture(e) => strictTransform(e, f) - case _ => future.value match { + case _ => future.value match { case None => val p = Promise[B]() future.onComplete { diff --git a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/HttpsProxyGraphStageSpec.scala b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/HttpsProxyGraphStageSpec.scala index 368eb6d6c..f1ba04010 100644 --- a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/HttpsProxyGraphStageSpec.scala +++ b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/HttpsProxyGraphStageSpec.scala @@ -136,7 +136,7 @@ class HttpsProxyGraphStageSpec extends PekkoSpecWithMaterializer { sink.expectError() match { case _: ProxyConnectionFailedException => - case e => + case e => fail(s"should be ProxyConnectionFailedException, caught ${e.getClass.getName} instead") } } diff --git a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/parsing/HttpHeaderParserSpec.scala b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/parsing/HttpHeaderParserSpec.scala index 888427164..04ef111f4 100644 --- a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/parsing/HttpHeaderParserSpec.scala +++ b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/parsing/HttpHeaderParserSpec.scala @@ -242,7 +242,8 @@ abstract class HttpHeaderParserSpec(mode: String, newLine: String) extends Pekko "produce an error message for lines with a too-long header value" in new TestSetup() { noException should be thrownBy parseLine(s"foo: ${nextRandomString(nextRandomAlphaNumChar _, 1000)}${newLine}x") - (the[ParsingException] thrownBy parseLine(s"foo: ${nextRandomString(nextRandomAlphaNumChar _, 1001)}${newLine}x") should have).message( + (the[ParsingException] thrownBy parseLine( + s"foo: ${nextRandomString(nextRandomAlphaNumChar _, 1001)}${newLine}x") should have).message( "HTTP header value exceeds the configured limit of 1000 characters") } diff --git a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/rendering/ResponseRendererSpec.scala b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/rendering/ResponseRendererSpec.scala index 23146eaf2..c3bfb4756 100644 --- a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/rendering/ResponseRendererSpec.scala +++ b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/rendering/ResponseRendererSpec.scala @@ -710,7 +710,7 @@ class ResponseRendererSpec extends AnyFreeSpec with Matchers with BeforeAndAfter Source.single(ctx), rendererFactory.renderer.named("renderer") .map { - case ResponseRenderingOutput.HttpData(bytes) => bytes + case ResponseRenderingOutput.HttpData(bytes) => bytes case _: ResponseRenderingOutput.SwitchToOtherProtocol => throw new IllegalStateException("Didn't expect protocol switch response") }) diff --git a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/server/HttpServerTestSetupBase.scala b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/server/HttpServerTestSetupBase.scala index 6f15f44da..606d67935 100644 --- a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/server/HttpServerTestSetupBase.scala +++ b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/server/HttpServerTestSetupBase.scala @@ -48,7 +48,7 @@ abstract class HttpServerTestSetupBase { RunnableGraph.fromGraph(GraphDSL.createGraph(modifyServer(Http().serverLayer(settings))) { implicit b => server => import GraphDSL.Implicits._ - Source.fromPublisher(netIn) ~> Flow[ByteString].map(SessionBytes(null, _)) ~> server.in2 + Source.fromPublisher(netIn) ~> Flow[ByteString].map(SessionBytes(null, _)) ~> server.in2 server.out1 ~> Flow[SslTlsOutbound].collect { case SendBytes(x) => x }.buffer(1, OverflowStrategy.backpressure) ~> netOut.sink server.out2 ~> Sink.fromSubscriber(requests) diff --git a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/BitBuilder.scala b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/BitBuilder.scala index 59a498e8c..6136d953f 100644 --- a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/BitBuilder.scala +++ b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/BitBuilder.scala @@ -83,7 +83,7 @@ class BitSpecParser(val input: ParserInput) extends parboiled2.Parser { import Bits._ def parseBits(): Try[Bits] = bits.run() match { - case s: Success[Bits] => s + case s: Success[Bits] => s case Failure(e: ParseError) => Failure(new RuntimeException(formatError(e, new ErrorFormatter(showTraces = true)))) case _ => throw new IllegalStateException() diff --git a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/WSClientAutobahnTest.scala b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/WSClientAutobahnTest.scala index 1a45add64..aec0fe995 100644 --- a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/WSClientAutobahnTest.scala +++ b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/WSClientAutobahnTest.scala @@ -184,7 +184,7 @@ object WSClientAutobahnTest extends App { val sink = Sink.head[Message] runWs(uri, Flow.fromSinkAndSourceMat(sink, Source.maybe[Message])(Keep.left)).flatMap { case tm: TextMessage => tm.textStream.runWith(Sink.fold("")(_ + _)) - case other => + case other => throw new IllegalStateException(s"unexpected element of type ${other.getClass}") } } diff --git a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/GracefulTerminationSpec.scala b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/GracefulTerminationSpec.scala index 9fdb47d3c..12c9059cd 100644 --- a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/GracefulTerminationSpec.scala +++ b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/GracefulTerminationSpec.scala @@ -225,7 +225,7 @@ class GracefulTerminationSpec .mapMaterializedValue { conn => val result = Promise[Http.OutgoingConnection]() conn.onComplete { - case Success(s) => result.trySuccess(s) + case Success(s) => result.trySuccess(s) case Failure(ex) => log.debug(s"Delaying failure ${ex.getMessage}") system.scheduler.scheduleOnce(100.millis)(result.tryFailure(ex)) diff --git a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/TestServer.scala b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/TestServer.scala index aa465d22a..59dcef2cc 100644 --- a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/TestServer.scala +++ b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/TestServer.scala @@ -52,8 +52,8 @@ object TestServer extends App { case Some(upgrade) => upgrade.handleMessages(echoWebSocketService) // needed for running the autobahn test suite case None => index } - case HttpRequest(GET, Uri.Path("/ping"), _, _, _) => HttpResponse(entity = "PONG!") - case HttpRequest(GET, Uri.Path("/crash"), _, _, _) => sys.error("BOOM!") + case HttpRequest(GET, Uri.Path("/ping"), _, _, _) => HttpResponse(entity = "PONG!") + case HttpRequest(GET, Uri.Path("/crash"), _, _, _) => sys.error("BOOM!") case req @ HttpRequest(GET, Uri.Path("/ws-greeter"), _, _, _) => req.attribute(webSocketUpgrade) match { case Some(upgrade) => upgrade.handleMessages(greeterWebSocketService) diff --git a/http-core/src/test/scala/org/apache/pekko/testkit/PekkoSpec.scala b/http-core/src/test/scala/org/apache/pekko/testkit/PekkoSpec.scala index a146c0850..d40bbc514 100644 --- a/http-core/src/test/scala/org/apache/pekko/testkit/PekkoSpec.scala +++ b/http-core/src/test/scala/org/apache/pekko/testkit/PekkoSpec.scala @@ -149,7 +149,7 @@ abstract class PekkoBaseSpec(_system: ActorSystem) def spawn(dispatcherId: String = Dispatchers.DefaultDispatcherId)(body: => Unit): Unit = Future(body)(system.dispatchers.lookup(dispatcherId)) - override def expectedTestDuration: FiniteDuration = 60 seconds + override def expectedTestDuration: FiniteDuration = 60.seconds def muteDeadLetters(messageClasses: Class[_]*)(sys: ActorSystem = system): Unit = if (!sys.log.isDebugEnabled) { diff --git a/http-cors/src/test/scala/org/apache/pekko/http/cors/CorsDirectivesSpec.scala b/http-cors/src/test/scala/org/apache/pekko/http/cors/CorsDirectivesSpec.scala index 8d4bd81b8..41a366724 100644 --- a/http-cors/src/test/scala/org/apache/pekko/http/cors/CorsDirectivesSpec.scala +++ b/http-cors/src/test/scala/org/apache/pekko/http/cors/CorsDirectivesSpec.scala @@ -280,7 +280,7 @@ class CorsDirectivesSpec extends AnyWordSpec with Matchers with Directives with "reject pre-flight requests with invalid header" in { val settings = referenceSettings.withAllowedHeaders(HttpHeaderRange()) val invalidHeader = "X-header" - Options() ~> Origin(exampleOrigin) ~> `Access-Control-Request-Method`(GET) ~> + Options() ~> Origin(exampleOrigin) ~> `Access-Control-Request-Method`(GET) ~> `Access-Control-Request-Headers`(invalidHeader) ~> { route(settings) } ~> check { @@ -351,7 +351,7 @@ class CorsDirectivesSpec extends AnyWordSpec with Matchers with Directives with } "handle a pre-flight request with invalid headers" in { - Options() ~> Origin(exampleOrigin) ~> `Access-Control-Request-Method`(GET) ~> + Options() ~> Origin(exampleOrigin) ~> `Access-Control-Request-Method`(GET) ~> `Access-Control-Request-Headers`("X-a", "X-b") ~> { sealedRoute } ~> check { @@ -361,7 +361,7 @@ class CorsDirectivesSpec extends AnyWordSpec with Matchers with Directives with } "handle multiple CORS rejections" in { - Options() ~> Origin(HttpOrigin("http://invalid.com")) ~> `Access-Control-Request-Method`(PATCH) ~> + Options() ~> Origin(HttpOrigin("http://invalid.com")) ~> `Access-Control-Request-Method`(PATCH) ~> `Access-Control-Request-Headers`("X-a", "X-b") ~> { sealedRoute } ~> check { diff --git a/http-scalafix/scalafix-rules/src/main/scala/org/apache/pekko/http/fix/MigrateToServerBuilder.scala b/http-scalafix/scalafix-rules/src/main/scala/org/apache/pekko/http/fix/MigrateToServerBuilder.scala index 02f604df0..1916c24e2 100644 --- a/http-scalafix/scalafix-rules/src/main/scala/org/apache/pekko/http/fix/MigrateToServerBuilder.scala +++ b/http-scalafix/scalafix-rules/src/main/scala/org/apache/pekko/http/fix/MigrateToServerBuilder.scala @@ -108,7 +108,7 @@ class MigrateToServerBuilder extends SemanticRule("MigrateToServerBuilder") { case t @ q"$http.bindAndHandle(..$params)" if isHttpExt(http) => patch(t, http, bindAndHandleTargetMethod) case t @ q"$http.bindAndHandleSync(..$params)" if isHttpExt(http) => patch(t, http, _ => "bindSync") - case t @ q"$http.bind(..$params)" if isHttpExt(http) => + case t @ q"$http.bind(..$params)" if isHttpExt(http) => val args = Seq("interface", "port", "connectionContext", "settings", "log") val argExps = namedArgMap(args, params) diff --git a/http-testkit/src/main/scala/org/apache/pekko/http/javadsl/testkit/TestRouteResult.scala b/http-testkit/src/main/scala/org/apache/pekko/http/javadsl/testkit/TestRouteResult.scala index 4a73621b5..8ad880b4a 100644 --- a/http-testkit/src/main/scala/org/apache/pekko/http/javadsl/testkit/TestRouteResult.scala +++ b/http-testkit/src/main/scala/org/apache/pekko/http/javadsl/testkit/TestRouteResult.scala @@ -42,7 +42,7 @@ abstract class TestRouteResult(_result: Future[RouteResult], awaitAtMost: Finite materializer: Materializer) { private def _response = _result.awaitResult(awaitAtMost) match { - case scaladsl.server.RouteResult.Complete(r) => r + case scaladsl.server.RouteResult.Complete(r) => r case scaladsl.server.RouteResult.Rejected(rejections) => doFail("Expected route to complete, but was instead rejected with " + rejections) } diff --git a/http-tests/src/multi-jvm/scala/org/apache/pekko/remote/testkit/MultiNodeConfig.scala b/http-tests/src/multi-jvm/scala/org/apache/pekko/remote/testkit/MultiNodeConfig.scala index 55a0e6150..d7c56c075 100644 --- a/http-tests/src/multi-jvm/scala/org/apache/pekko/remote/testkit/MultiNodeConfig.scala +++ b/http-tests/src/multi-jvm/scala/org/apache/pekko/remote/testkit/MultiNodeConfig.scala @@ -426,7 +426,7 @@ abstract class MultiNodeSpec(val myself: RoleName, _system: ActorSystem, _roles: val deployString = replacements.foldLeft(str) { (base, r) => val tag = r.tag base.indexOf(tag) match { - case -1 => base + case -1 => base case start => val replaceWith = try @@ -446,7 +446,7 @@ abstract class MultiNodeSpec(val myself: RoleName, _system: ActorSystem, _roles: import scala.jdk.CollectionConverters._ ConfigFactory.parseString(deployString).root.asScala.foreach { case (key, value: ConfigObject) => deployer.parseConfig(key, value.toConfig).foreach(deployer.deploy) - case (key, x) => + case (key, x) => throw new IllegalArgumentException(s"key $key must map to deployment section, not simple value $x") } } diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/DiscardEntityDefaultExceptionHandlerSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/DiscardEntityDefaultExceptionHandlerSpec.scala index 5e4469979..90f283a94 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/DiscardEntityDefaultExceptionHandlerSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/DiscardEntityDefaultExceptionHandlerSpec.scala @@ -54,7 +54,7 @@ class DiscardEntityDefaultExceptionHandlerSpec extends RoutingSpec with ScalaFut "rejectEntity by default" in new Fixture { streamConsumed shouldBe false Get("/crash", HttpEntity(`text/plain(UTF-8)`, Source[ByteString](thousandElements))) ~> Route.seal( - route) ~> check { + route) ~> check { status shouldBe InternalServerError eventually { // Stream will be eventually consumed, once all the stream bytes are successfully discarded streamConsumed shouldBe true @@ -65,7 +65,7 @@ class DiscardEntityDefaultExceptionHandlerSpec extends RoutingSpec with ScalaFut "rejectEntity by default even if consumed already" in new Fixture { streamConsumed shouldBe false Get("/crashAfterConsuming", HttpEntity(`text/plain(UTF-8)`, Source[ByteString](thousandElements))) ~> Route.seal( - route) ~> check { + route) ~> check { // Stream should be consumed immediately after the request finishes streamConsumed shouldBe true status shouldBe InternalServerError diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/CacheConditionDirectivesSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/CacheConditionDirectivesSpec.scala index fa4b80ff3..85b8e92a4 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/CacheConditionDirectivesSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/CacheConditionDirectivesSpec.scala @@ -49,7 +49,7 @@ class CacheConditionDirectivesSpec extends RoutingSpec { headers should contain theSameElementsAs responseHeaders } Get() ~> `If-None-Match`(EntityTag("old")) ~> `If-Modified-Since`( - timestamp - 1000) ~> taggedAndTimestamped ~> check { + timestamp - 1000) ~> taggedAndTimestamped ~> check { status shouldEqual OK headers should contain theSameElementsAs responseHeaders } diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/FileAndResourceDirectivesSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/FileAndResourceDirectivesSpec.scala index d0e11fa1d..e183a62ba 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/FileAndResourceDirectivesSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/FileAndResourceDirectivesSpec.scala @@ -451,7 +451,7 @@ class FileAndResourceDirectivesSpec extends RoutingSpec with Inspectors with Ins } } "properly render a sub directory with a path prefix" in { - Get("/files/sub/") ~> withSettings(settings)( + Get("/files/sub/") ~> withSettings(settings)( pathPrefix("files")(listDirectoryContents(base + "/someDir"))) ~> check { eraseDateTime(responseAs[String]) shouldEqual prep { """ @@ -471,7 +471,7 @@ class FileAndResourceDirectivesSpec extends RoutingSpec with Inspectors with Ins } } "properly render an empty top-level directory with a path prefix" in { - Get("/files/") ~> withSettings(settings)( + Get("/files/") ~> withSettings(settings)( pathPrefix("files")(listDirectoryContents(base + "/subDirectory/emptySub"))) ~> check { eraseDateTime(responseAs[String]) shouldEqual prep { """ diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/FormFieldDirectivesSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/FormFieldDirectivesSpec.scala index 7dd17b205..6f5729770 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/FormFieldDirectivesSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/FormFieldDirectivesSpec.scala @@ -294,7 +294,7 @@ class FormFieldDirectivesSpec extends RoutingSpec { "reject with MalformedRequestContentRejection if request entity fails" in { val failedSource = Source.failed(new IllegalStateException("Form was stapled wrongly")) Post("/", HttpEntity(`application/x-www-form-urlencoded`, failedSource)) ~> - formFieldSeq { echoComplete } ~> + formFieldSeq { echoComplete } ~> check { rejection shouldBe a[MalformedRequestContentRejection] } diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/FutureDirectivesSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/FutureDirectivesSpec.scala index 1a3a4f71c..147c725db 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/FutureDirectivesSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/FutureDirectivesSpec.scala @@ -65,7 +65,7 @@ class FutureDirectivesSpec extends RoutingSpec with Inside with TestKitBase { } } "catch an exception in the failure case" in { - Get() ~> showEx( + Get() ~> showEx( onComplete(Future.failed[String](new RuntimeException("no"))) { throwTestException("EX when ") }) ~> check { status shouldEqual StatusCodes.InternalServerError responseAs[String] shouldEqual s"Oops. org.apache.pekko.http.scaladsl.server.directives.FutureDirectivesSpec$$TestException: EX when Failure(java.lang.RuntimeException: no)" @@ -114,7 +114,7 @@ class FutureDirectivesSpec extends RoutingSpec with Inside with TestKitBase { }, breakerResetTimeout + 1.second) } "catch an exception in the success case" in new TestWithCircuitBreaker { - Get() ~> showEx( + Get() ~> showEx( onCompleteWithBreaker(breaker)(Future.successful("ok")) { throwTestException("EX when ") }) ~> check { status shouldEqual StatusCodes.InternalServerError responseAs[String] shouldEqual s"Oops. org.apache.pekko.http.scaladsl.server.directives.FutureDirectivesSpec$$TestException: EX when Success(ok)" @@ -181,7 +181,7 @@ class FutureDirectivesSpec extends RoutingSpec with Inside with TestKitBase { } } "catch an exception during recovery" in { - Get() ~> showEx( + Get() ~> showEx( completeOrRecoverWith(Future.failed[String](TestException)) { throwTestException("EX when ") }) ~> check { status shouldEqual StatusCodes.InternalServerError responseAs[String] shouldEqual s"Oops. org.apache.pekko.http.scaladsl.server.directives.FutureDirectivesSpec$$TestException: EX when org.apache.pekko.http.scaladsl.server.directives.FutureDirectivesSpec$$TestException$$: XXX" diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/MarshallingDirectivesSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/MarshallingDirectivesSpec.scala index f93f9a9f2..f5b22aa19 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/MarshallingDirectivesSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/MarshallingDirectivesSpec.scala @@ -229,8 +229,8 @@ class MarshallingDirectivesSpec extends RoutingSpec with Inside { "result in an UnacceptedResponseContentTypeRejection rejection if there is no marshaller supporting the requests Accept-Charset header" in ( Put("/", HttpEntity(ContentTypes.`text/html(UTF-8)`, "42")) ~> addHeaders(Accept(`text/xxml`), - `Accept-Charset`(`UTF-16`)) ~> - handleWith(times2) ~> check { + `Accept-Charset`(`UTF-16`)) ~> + handleWith(times2) ~> check { rejection shouldEqual UnacceptedResponseContentTypeRejection(Set(`application/xhtml+xml`, `text/xxml`)) }) } diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/ParameterDirectivesSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/ParameterDirectivesSpec.scala index d90a28096..71c30de36 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/ParameterDirectivesSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/ParameterDirectivesSpec.scala @@ -71,7 +71,7 @@ class ParameterDirectivesSpec extends AnyFreeSpec with GenericRoutingSpec with I Unmarshaller.strict[UserId, AnotherUserId](userId => AnotherUserId(userId.id)) Get("/?id=45") ~> { parameter("id".as[Int].as(UserIdUnmarshaller)) { echoComplete } - } ~> check { responseAs[String] shouldEqual "UserId(45)" } + } ~> check { responseAs[String] shouldEqual "UserId(45)" } Get("/?id=45") ~> { parameter("id".as[Int].as(UserIdUnmarshaller).as[AnotherUserId]) { echoComplete } } ~> check { responseAs[String] shouldEqual "AnotherUserId(45)" } @@ -150,7 +150,7 @@ class ParameterDirectivesSpec extends AnyFreeSpec with GenericRoutingSpec with I "extract parameter values as Boolean" in { Get("/?really=true") ~> { parameter("really".as[Boolean]) { echoComplete } - } ~> check { responseAs[String] shouldEqual "true" } + } ~> check { responseAs[String] shouldEqual "true" } Get("/?really=no") ~> { parameter("really".as[Boolean]) { echoComplete } } ~> check { responseAs[String] shouldEqual "false" } @@ -158,7 +158,7 @@ class ParameterDirectivesSpec extends AnyFreeSpec with GenericRoutingSpec with I "extract numeric parameter value as Boolean" in { Get("/?really=1") ~> { parameter("really".as[Boolean]) { echoComplete } - } ~> check { responseAs[String] shouldEqual "true" } + } ~> check { responseAs[String] shouldEqual "true" } Get("/?really=0") ~> { parameter("really".as[Boolean]) { echoComplete } } ~> check { responseAs[String] shouldEqual "false" } diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/PathDirectivesSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/PathDirectivesSpec.scala index 1168b52b9..859ed3472 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/PathDirectivesSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/PathDirectivesSpec.scala @@ -517,11 +517,11 @@ class PathDirectivesSpec extends RoutingSpec with Inside { } "redirect with the given redirection status code" in { - Get("/foo/bar") ~> + Get("/foo/bar") ~> redirectToTrailingSlashIfMissing(MovedPermanently) { completeOk } ~> check { status shouldEqual MovedPermanently } - Get("/foo/bar/") ~> + Get("/foo/bar/") ~> redirectToTrailingSlashIfMissing(MovedPermanently) { completeOk } ~> check { status shouldEqual StatusCodes.OK } } @@ -547,7 +547,7 @@ class PathDirectivesSpec extends RoutingSpec with Inside { } "redirect with the given redirection status code" in { - Get("/foo/bar/") ~> + Get("/foo/bar/") ~> redirectToNoTrailingSlashIfPresent(MovedPermanently) { completeOk } ~> check { status shouldEqual MovedPermanently } } diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/RouteDirectivesSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/RouteDirectivesSpec.scala index a6115b98b..ea46fa8bf 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/RouteDirectivesSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/RouteDirectivesSpec.scala @@ -103,7 +103,7 @@ class RouteDirectivesSpec extends AnyWordSpec with GenericRoutingSpec { } complete { registerUser(name).map[ToResponseMarshallable] { - case Registered(_) => HttpEntity.Empty + case Registered(_) => HttpEntity.Empty case AlreadyRegistered => import SprayJsonSupport._ diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/WebSocketDirectivesSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/WebSocketDirectivesSpec.scala index 124b70da6..ae3c5cfe5 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/WebSocketDirectivesSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/WebSocketDirectivesSpec.scala @@ -103,7 +103,7 @@ class WebSocketDirectivesSpec extends RoutingSpec { def greeter: Flow[Message, Message, Any] = Flow[Message].mapConcat { - case tm: TextMessage => TextMessage(Source.single("Hello ") ++ tm.textStream ++ Source.single("!")) :: Nil + case tm: TextMessage => TextMessage(Source.single("Hello ") ++ tm.textStream ++ Source.single("!")) :: Nil case bm: BinaryMessage => // ignore binary messages bm.dataStream.runWith(Sink.ignore) Nil diff --git a/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/DebuggingDirectives.scala b/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/DebuggingDirectives.scala index 657fb97de..b77974a7e 100644 --- a/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/DebuggingDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/DebuggingDirectives.scala @@ -100,7 +100,7 @@ abstract class DebuggingDirectives extends CookieDirectives { showRejection: BiFunction[HttpRequest, JList[Rejection], LogEntry], inner: Supplier[Route]) = RouteAdapter { D.logRequestResult(LoggingMagnet.forRequestResponseFromFullShow(request => { - case RouteResult.Complete(response) => Some(showSuccess.apply(request, response).asScala) + case RouteResult.Complete(response) => Some(showSuccess.apply(request, response).asScala) case RouteResult.Rejected(rejections) => Some(showRejection.apply(request, rejections.map(_.asJava).asJava).asScala) })) { diff --git a/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/HeaderDirectives.scala b/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/HeaderDirectives.scala index 91e9fbe27..3f3b99eb2 100644 --- a/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/HeaderDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/HeaderDirectives.scala @@ -44,7 +44,7 @@ abstract class HeaderDirectives extends FutureDirectives { def checkSameOrigin(allowed: HttpOriginRange, inner: jf.Supplier[Route]): Route = allowed match { case HttpOriginRanges.ALL | pekko.http.scaladsl.model.headers.HttpOriginRange.`*` => pass(inner) - case _ => RouteAdapter { + case _ => RouteAdapter { // safe, we know it's not the `*` header val default = allowed.asInstanceOf[pekko.http.scaladsl.model.headers.HttpOriginRange.Default] D.checkSameOrigin(default) { inner.get().delegate } diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/client/RequestBuilding.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/client/RequestBuilding.scala index a1fce3899..bab810ce9 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/client/RequestBuilding.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/client/RequestBuilding.scala @@ -55,7 +55,7 @@ trait RequestBuilding extends TransformerPipelineSupport { def apply[T](uri: Uri, content: Option[T])(implicit m: ToEntityMarshaller[T], timeout: Timeout = Timeout(1.second), ec: ExecutionContext): HttpRequest = content match { - case None => apply(uri, HttpEntity.Empty) + case None => apply(uri, HttpEntity.Empty) case Some(value) => val entity = Await.result(Marshal(value).to[RequestEntity], timeout.duration) apply(uri, entity) diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/common/StrictForm.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/common/StrictForm.scala index 6f4d3f08d..2d469b5b6 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/common/StrictForm.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/common/StrictForm.scala @@ -73,7 +73,7 @@ object StrictForm { Unmarshaller.withMaterializer(implicit ec => implicit mat => { case FromString(value) => fsu(value) - case FromPart(value) => + case FromPart(value) => val charsetName = value.entity.contentType.asInstanceOf[ContentType.NonBinary].charset.nioCharset.name fsu(value.entity.data.decodeString(charsetName)) }) @@ -123,7 +123,8 @@ object StrictForm { } } - implicit def unmarshaller(implicit + implicit def unmarshaller( + implicit formDataUM: FromEntityUnmarshaller[FormData], multipartUM: FromEntityUnmarshaller[Multipart.FormData]): FromEntityUnmarshaller[StrictForm] = Unmarshaller.withMaterializer { implicit ec => implicit fm => entity => diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/RejectionHandler.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/RejectionHandler.scala index 8bb8934e4..475ef6e97 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/RejectionHandler.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/RejectionHandler.scala @@ -48,7 +48,7 @@ trait RejectionHandler extends (immutable.Seq[Rejection] => Option[Route]) { sel */ def withFallback(that: RejectionHandler): RejectionHandler = (this, that) match { - case (a: BuiltRejectionHandler, _) if a.isDefault => this // the default handler already handles everything + case (a: BuiltRejectionHandler, _) if a.isDefault => this // the default handler already handles everything case (a: BuiltRejectionHandler, b: BuiltRejectionHandler) => new BuiltRejectionHandler(a.cases ++ b.cases, a.notFound.orElse(b.notFound), b.isDefault) case _ => new RejectionHandler { diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/Route.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/Route.scala index d0571b5f1..cbacfdea0 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/Route.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/Route.scala @@ -43,7 +43,8 @@ object Route { * - Consequently, no route alternatives will be tried that were combined with this route * using the ``~`` on routes or the [[Directive.|]] operator on directives. */ - def seal(route: Route)(implicit + def seal(route: Route)( + implicit routingSettings: RoutingSettings = null, rejectionHandler: RejectionHandler = RejectionHandler.default, exceptionHandler: ExceptionHandler = null): Route = { diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/RouteConcatenation.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/RouteConcatenation.scala index 4bb9f9a2f..022259e2b 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/RouteConcatenation.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/RouteConcatenation.scala @@ -53,7 +53,7 @@ object RouteConcatenation extends RouteConcatenation { def ~(other: Route): Route = { ctx => import ctx.executionContext route(ctx).fast.flatMap { - case x: RouteResult.Complete => FastFuture.successful(x) + case x: RouteResult.Complete => FastFuture.successful(x) case RouteResult.Rejected(outerRejections) => other(ctx).fast.map { case x: RouteResult.Complete => x diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/CodingDirectives.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/CodingDirectives.scala index 002db5360..e5025c4b7 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/CodingDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/CodingDirectives.scala @@ -171,7 +171,7 @@ object CodingDirectives extends CodingDirectives { val bestEncoder = negotiator.pickEncoding(encodings).flatMap(be => encoders.find(_.encoding == be)) bestEncoder match { case Some(encoder) => mapResponse(encoder.encodeMessage(_)) - case _ => + case _ => if (encoders.contains(Coders.NoCoding) && !negotiator.hasMatchingFor(HttpEncodings.identity)) pass else reject(UnacceptedResponseEncodingRejection(encodings.toSet)) } diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/FileAndResourceDirectives.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/FileAndResourceDirectives.scala index 788629102..eb05cc23f 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/FileAndResourceDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/FileAndResourceDirectives.scala @@ -156,7 +156,7 @@ trait FileAndResourceDirectives { val dirs = directories.flatMap { dir => safeDirectoryChildPath(withTrailingSlash(dir), remainingPath, ctx.log) match { - case "" => None + case "" => None case fileName => val file = new File(fileName) if (file.isDirectory && file.canRead) Some(file) else None @@ -247,8 +247,8 @@ object FileAndResourceDirectives extends FileAndResourceDirectives { import java.lang.StringBuilder @tailrec def rec(p: Uri.Path, result: StringBuilder = new StringBuilder(base)): String = p match { - case Uri.Path.Empty => result.toString - case Uri.Path.Slash(tail) => rec(tail, result.append(separator)) + case Uri.Path.Empty => result.toString + case Uri.Path.Slash(tail) => rec(tail, result.append(separator)) case Uri.Path.Segment(head, tail) => if (head.indexOf('/') >= 0 || head.indexOf('\\') >= 0 || head == "..") { log.warning("File-system path for base [{}] and Uri.Path [{}] contains suspicious path segment [{}], " + diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/FormFieldDirectives.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/FormFieldDirectives.scala index c8d5feef7..9534cc7f3 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/FormFieldDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/FormFieldDirectives.scala @@ -76,7 +76,7 @@ object FormFieldDirectives extends FormFieldDirectives { } }.flatMap { sequenceF => onComplete(sequenceF).flatMap { - case Success(x) => provide(x) + case Success(x) => provide(x) case Failure(x: UnsupportedContentTypeException) => reject(UnsupportedRequestContentTypeRejection(x.supported, x.actualContentType)) case Failure(x) => reject(MalformedRequestContentRejection(x.getMessage.nullAsEmpty, x)) @@ -171,8 +171,8 @@ object FormFieldDirectives extends FormFieldDirectives { protected def handleFieldResult[T](fieldName: String, result: Future[T]): Directive1[T] = onComplete(result).flatMap { - case Success(x) => provide(x) - case Failure(Unmarshaller.NoContentException) => reject(MissingFormFieldRejection(fieldName)) + case Success(x) => provide(x) + case Failure(Unmarshaller.NoContentException) => reject(MissingFormFieldRejection(fieldName)) case Failure(x: UnsupportedContentTypeException) => reject(UnsupportedRequestContentTypeRejection(x.supported, x.actualContentType)) case Failure(x) => reject(MalformedFormFieldRejection(fieldName, x.getMessage.nullAsEmpty, Option(x.getCause))) diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/MarshallingDirectives.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/MarshallingDirectives.scala index edf87b87f..fd2727331 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/MarshallingDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/MarshallingDirectives.scala @@ -45,13 +45,13 @@ trait MarshallingDirectives { import ctx.executionContext import ctx.materializer onComplete(um(ctx.request)).flatMap { - case Success(value) => provide(value) - case Failure(RejectionError(r)) => reject(r) - case Failure(Unmarshaller.NoContentException) => reject(RequestEntityExpectedRejection) + case Success(value) => provide(value) + case Failure(RejectionError(r)) => reject(r) + case Failure(Unmarshaller.NoContentException) => reject(RequestEntityExpectedRejection) case Failure(x: UnsupportedContentTypeException) => reject(UnsupportedRequestContentTypeRejection(x.supported, x.actualContentType)) case Failure(x: IllegalArgumentException) => reject(ValidationRejection(x.getMessage.nullAsEmpty, Some(x))) - case Failure(x: ExceptionWithErrorInfo) => + case Failure(x: ExceptionWithErrorInfo) => reject(MalformedRequestContentRejection(x.info.format(ctx.settings.verboseErrorMessages), x)) case Failure(x) => reject(MalformedRequestContentRejection(x.getMessage.nullAsEmpty, x)) } diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/ParameterDirectives.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/ParameterDirectives.scala index 593cfd85b..bde69c4f8 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/ParameterDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/ParameterDirectives.scala @@ -137,7 +137,7 @@ object ParameterDirectives extends ParameterDirectives { import ctx.materializer onComplete(fsou(ctx.request.uri.query().get(paramName))).flatMap { case Success(value) if value == requiredValue => pass - case Success(value) => + case Success(value) => reject(InvalidRequiredValueForQueryParamRejection(paramName, requiredValue.toString, value.toString)) case _ => reject(MissingQueryParamRejection(paramName)) } diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/RangeDirectives.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/RangeDirectives.scala index 46669174e..c82bfc32c 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/RangeDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/RangeDirectives.scala @@ -147,7 +147,7 @@ trait RangeDirectives { ranges.filter(satisfiable(length)) match { case Nil => ctx.reject(UnsatisfiableRangeRejection(ranges, length)) case Seq(satisfiableRange) => ctx.complete(rangeResponse(satisfiableRange, entity, length, headers)) - case satisfiableRanges => + case satisfiableRanges => ctx.complete((PartialContent, headers, multipartRanges(satisfiableRanges, entity))) } case None => diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/SecurityDirectives.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/SecurityDirectives.scala index c32a76cf4..f5468dcee 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/SecurityDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/SecurityDirectives.scala @@ -215,7 +215,7 @@ trait SecurityDirectives { authenticator: Option[C] => Future[AuthenticationResult[T]]): AuthenticationDirective[T] = extractCredentials.flatMap { cred => onSuccess(authenticator(cred)).flatMap { - case Right(user) => provide(user) + case Right(user) => provide(user) case Left(challenge) => val cause = if (cred.isEmpty) CredentialsMissing else CredentialsRejected reject(AuthenticationFailedRejection(cause, challenge)): Directive1[T] diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/TimeoutDirectives.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/TimeoutDirectives.scala index 08d653634..99c39cf3d 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/TimeoutDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/TimeoutDirectives.scala @@ -36,7 +36,7 @@ trait TimeoutDirectives { def extractRequestTimeout: Directive1[Duration] = Directive { inner => ctx => val timeout = ctx.request.header[`Timeout-Access`] match { case Some(t) => t.timeoutAccess.timeout - case _ => + case _ => ctx.log.warning("extractRequestTimeout was used in route however no request-timeout is set!") Duration.Inf } diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/settings/OversizedSseStrategy.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/settings/OversizedSseStrategy.scala index a0d6b9644..fe9feb7fb 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/settings/OversizedSseStrategy.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/settings/OversizedSseStrategy.scala @@ -44,7 +44,7 @@ object OversizedSseStrategy { case "log-and-skip" => LogAndSkip case "truncate" => Truncate case "dead-letter" => DeadLetter - case _ => throw new IllegalArgumentException( + case _ => throw new IllegalArgumentException( s"Invalid oversized-message-handling: '$value'. Valid options are: fail-stream, log-and-skip, truncate, dead-letter") } diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/unmarshalling/MultipartUnmarshallers.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/unmarshalling/MultipartUnmarshallers.scala index 0fed0e427..6db02b8d9 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/unmarshalling/MultipartUnmarshallers.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/unmarshalling/MultipartUnmarshallers.scala @@ -104,7 +104,7 @@ trait MultipartUnmarshallers { case BodyPartStart(headers, createEntity) => val entity = createEntity(Source.empty) match { case x: HttpEntity.Strict => x - case x => + case x => throw new IllegalStateException("Unexpected entity type from strict BodyPartParser: " + x) } builder += createStrictBodyPart(entity, headers) diff --git a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/H2SpecIntegrationSpec.scala b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/H2SpecIntegrationSpec.scala index 9907cbf60..6f64e97b1 100644 --- a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/H2SpecIntegrationSpec.scala +++ b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/H2SpecIntegrationSpec.scala @@ -304,11 +304,12 @@ class H2SpecIntegrationSpec extends PekkoFreeSpec( val stdout = new StringBuffer() val stderr = new StringBuffer() - val command = Seq( // need to use Seq[String] form for command because executable path may contain spaces - executable, - "-k", "-t", - "-p", port.toString, - "-j", junitOutput.getPath) ++ + val command = + Seq( // need to use Seq[String] form for command because executable path may contain spaces + executable, + "-k", "-t", + "-p", port.toString, + "-j", junitOutput.getPath) ++ specSectionNumber.toList.map(number => s"http2/$number") log.debug(s"Executing h2spec: $command") diff --git a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2FrameHpackSupport.scala b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2FrameHpackSupport.scala index 5bb6e0d2b..8549de343 100644 --- a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2FrameHpackSupport.scala +++ b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2FrameHpackSupport.scala @@ -73,7 +73,7 @@ trait Http2FrameHpackSupport extends Http2FrameProbeDelegator with Http2FrameSen header match { case (":status", value) => old.withStatus(value.toInt) case ("content-length", value) if value.toLong == 0 => old.withEntity(HttpEntity.Empty) - case ("content-length", value) => + case ("content-length", value) => old.withEntity(HttpEntity.Default(old.entity.contentType, value.toLong, Source.empty)) case ("content-type", value) => old.withEntity(old.entity.withContentType(ContentType.parse(value).toOption.get)) diff --git a/http2-tests/src/test/scala/org/apache/pekko/http/scaladsl/Http2ServerTest.scala b/http2-tests/src/test/scala/org/apache/pekko/http/scaladsl/Http2ServerTest.scala index c6d049e48..556e0b787 100644 --- a/http2-tests/src/test/scala/org/apache/pekko/http/scaladsl/Http2ServerTest.scala +++ b/http2-tests/src/test/scala/org/apache/pekko/http/scaladsl/Http2ServerTest.scala @@ -54,9 +54,9 @@ object Http2ServerTest extends App { } val syncHandler: HttpRequest => HttpResponse = { - case HttpRequest(GET, Uri.Path("/"), _, _, _) => index - case HttpRequest(GET, Uri.Path("/ping"), _, _, _) => HttpResponse(entity = "PONG!") - case HttpRequest(GET, Uri.Path("/image-page"), _, _, _) => imagePage + case HttpRequest(GET, Uri.Path("/"), _, _, _) => index + case HttpRequest(GET, Uri.Path("/ping"), _, _, _) => HttpResponse(entity = "PONG!") + case HttpRequest(GET, Uri.Path("/image-page"), _, _, _) => imagePage case HttpRequest(GET, Uri(_, _, p, _, _), _, _, _) if p.toString.startsWith("/image1") => HttpResponse(entity = HttpEntity(MediaTypes.`image/jpeg`, FileIO.fromPath(Paths.get("bigimage.jpg"), 100000).mapAsync(1)(slowDown(1)))) diff --git a/project/ValidatePullRequest.scala b/project/ValidatePullRequest.scala index 1825f57a9..75cf74b08 100644 --- a/project/ValidatePullRequest.scala +++ b/project/ValidatePullRequest.scala @@ -186,7 +186,7 @@ object ValidatePullRequest extends AutoPlugin { l.startsWith("http") || l.startsWith("parsing") || l.startsWith("docs") || - BuildFilesAndDirectories.exists(l startsWith)) + BuildFilesAndDirectories.exists(l.startsWith)) .map(l => l.takeWhile(_ != '/')) .toSet @@ -462,7 +462,7 @@ object AggregatePRValidation extends AutoPlugin { .map { case i @ Incomplete(node, tpe, message, causes, directCause) => def nodeName: String = node match { case Some(key: ScopedKey[_]) => showKey(key) - case Some(t: Task[_]) => + case Some(t: Task[_]) => t.info.name .orElse(t.info.attributes.get(taskDefinitionKey).map(showKey)) .getOrElse(t.info.toString) From 4e7ce3ffdc503da7f9e440f153355507009d5c03 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 13 Jan 2026 21:13:29 +0000 Subject: [PATCH 3/3] Add 'Reformat with scalafmt 3.10.3' to .git-blame-ignore-revs --- .git-blame-ignore-revs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 0d96d8827..b74bed2e8 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -10,3 +10,6 @@ b6e4bd242e5e5657f2bb17478c98abb06641eeae 8093f01074103e542f12c228c3720f9f9a06a53e ba209d86f235ad43cf7d5e0eaf941489058c90c8 a904e917d5851ebffc5e1eabbee70cf1685c4263 + +# Scala Steward: Reformat with scalafmt 3.10.3 +245df4a95b09802b6c1ea2dbc429259b368bd0ef