You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pekko.apache.org by jr...@apache.org on 2022/11/03 11:24:05 UTC

[incubator-pekko-http] 35/47: http2: enable Scala 3 for akka-http2-support (#4108)

This is an automated email from the ASF dual-hosted git repository.

jrudolph pushed a commit to branch scala-3
in repository https://gitbox.apache.org/repos/asf/incubator-pekko-http.git

commit de551668ec84f748034e8326ff9ea888dff841d4
Author: Arnout Engelen <ar...@bzzt.net>
AuthorDate: Mon Apr 25 11:51:46 2022 +0200

    http2: enable Scala 3 for akka-http2-support (#4108)
---
 .../impl/engine/http2/H2SpecIntegrationSpec.scala  |  4 ++--
 .../http/impl/engine/http2/H2cUpgradeSpec.scala    |  4 ++--
 .../http/impl/engine/http2/Http2ClientSpec.scala   |  7 ++++---
 .../http/impl/engine/http2/Http2ServerSpec.scala   |  8 +++++---
 .../impl/engine/http2/ProtocolSwitchSpec.scala     |  4 +++-
 .../impl/engine/http2/RequestParsingSpec.scala     | 22 +++++++++++-----------
 .../http/impl/engine/http2/TelemetrySpiSpec.scala  |  3 ++-
 .../engine/http2/WithInPendingUntilFixed.scala     | 16 ----------------
 .../impl/engine/http2/WithPriorKnowledgeSpec.scala |  2 +-
 .../engine/http2/framing/Http2FramingSpec.scala    |  2 +-
 .../scala/akka/http/scaladsl/Http2ServerTest.scala |  2 +-
 build.sbt                                          |  1 -
 12 files changed, 32 insertions(+), 43 deletions(-)

diff --git a/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/H2SpecIntegrationSpec.scala b/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/H2SpecIntegrationSpec.scala
index 1b9852450..5f9e2e492 100644
--- a/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/H2SpecIntegrationSpec.scala
+++ b/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/H2SpecIntegrationSpec.scala
@@ -10,7 +10,7 @@ import java.util.concurrent.atomic.AtomicBoolean
 import akka.http.impl.util.{ ExampleHttpContexts, WithLogCapturing }
 import akka.http.scaladsl.Http
 import akka.http.scaladsl.server.Directives
-import akka.stream.ActorMaterializer
+import akka.stream.{ ActorMaterializer, Materializer }
 import akka.testkit._
 import akka.util.ByteString
 import org.scalatest.concurrent.ScalaFutures
@@ -36,7 +36,7 @@ class H2SpecIntegrationSpec extends AkkaSpec(
   """) with Directives with ScalaFutures with WithLogCapturing {
 
   implicit val ec: ExecutionContext = system.dispatcher
-  implicit val mat = ActorMaterializer()
+  implicit val mat: Materializer = ActorMaterializer()
 
   override def expectedTestDuration = 5.minutes // because slow jenkins, generally finishes below 1 or 2 minutes
 
diff --git a/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/H2cUpgradeSpec.scala b/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/H2cUpgradeSpec.scala
index 3eb1ac8c0..6eb9eaa22 100644
--- a/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/H2cUpgradeSpec.scala
+++ b/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/H2cUpgradeSpec.scala
@@ -51,7 +51,7 @@ class H2cUpgradeSpec extends AkkaSpecWithMaterializer("""
       testWith(settings)
     }
 
-    def testWith(settings: String) {
+    def testWith(settings: String) = {
       val upgradeRequest =
         s"""GET / HTTP/1.1
 Host: localhost
@@ -62,7 +62,7 @@ HTTP2-Settings: $settings
       val frameProbe = Http2FrameProbe()
 
       Source.single(ByteString(upgradeRequest)).concat(Source.maybe)
-        .via(Tcp().outgoingConnection(binding.localAddress.getHostName, binding.localAddress.getPort))
+        .via(Tcp(system).outgoingConnection(binding.localAddress.getHostName, binding.localAddress.getPort))
         .runWith(frameProbe.sink)
 
       @tailrec def readToEndOfHeader(currentlyRead: String = ""): String =
diff --git a/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/Http2ClientSpec.scala b/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/Http2ClientSpec.scala
index c17031f19..c76aec5e0 100644
--- a/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/Http2ClientSpec.scala
+++ b/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/Http2ClientSpec.scala
@@ -42,9 +42,10 @@ import org.scalatest.concurrent.Eventually
 import org.scalatest.concurrent.PatienceConfiguration.Timeout
 
 import javax.net.ssl.SSLContext
-import scala.collection.immutable
+import scala.concurrent.ExecutionContext
 import scala.concurrent.Future
 import scala.concurrent.duration._
+import scala.collection.immutable
 
 /**
  * This tests the http2 client protocol logic.
@@ -60,7 +61,7 @@ class Http2ClientSpec extends AkkaSpecWithMaterializer("""
     akka.http.client.http2.log-frames = on
     akka.http.client.http2.completion-timeout = 500ms
   """)
-  with WithInPendingUntilFixed with Eventually {
+  with Eventually {
 
   override implicit val patience = PatienceConfig(5.seconds, 5.seconds)
   override def failOnSevereMessages: Boolean = true
@@ -932,7 +933,7 @@ class Http2ClientSpec extends AkkaSpecWithMaterializer("""
   }
 
   protected /* To make ByteFlag warnings go away */ abstract class TestSetupWithoutHandshake {
-    implicit def ec = system.dispatcher
+    implicit def ec: ExecutionContext = system.dispatcher
 
     private lazy val responseIn = TestSubscriber.probe[HttpResponse]()
     private lazy val requestOut = TestPublisher.probe[HttpRequest]()
diff --git a/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/Http2ServerSpec.scala b/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/Http2ServerSpec.scala
index 5268be3c9..da2861f6b 100644
--- a/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/Http2ServerSpec.scala
+++ b/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/Http2ServerSpec.scala
@@ -41,6 +41,7 @@ import org.scalatest.concurrent.PatienceConfiguration.Timeout
 import scala.collection.immutable
 import scala.concurrent.duration._
 import scala.concurrent.Await
+import scala.concurrent.ExecutionContext
 import scala.concurrent.Future
 import scala.concurrent.Promise
 
@@ -57,7 +58,7 @@ class Http2ServerSpec extends AkkaSpecWithMaterializer("""
     akka.http.server.remote-address-header = on
     akka.http.server.http2.log-frames = on
   """)
-  with WithInPendingUntilFixed with Eventually {
+  with Eventually {
   override def failOnSevereMessages: Boolean = true
 
   "The Http/2 server implementation" should {
@@ -1387,13 +1388,14 @@ class Http2ServerSpec extends AkkaSpecWithMaterializer("""
       }
       "reject incoming frames on already half-closed substream" in pending
 
-      "reject even-numbered client-initiated substreams" inPendingUntilFixed new SimpleRequestResponseRoundtripSetup {
+      "reject even-numbered client-initiated substreams" in pending /* new SimpleRequestResponseRoundtripSetup {
         network.sendHEADERS(2, endStream = true, endHeaders = true, HPackSpecExamples.C41FirstRequestWithHuffman)
         network.expectGOAWAY()
         // after GOAWAY we expect graceful completion after x amount of time
         // TODO: completion logic, wait?!
         expectGracefulCompletion()
       }
+      */
 
       "reject all other frames while waiting for CONTINUATION frames" in pending
 
@@ -1665,7 +1667,7 @@ class Http2ServerSpec extends AkkaSpecWithMaterializer("""
   }
 
   protected /* To make ByteFlag warnings go away */ abstract class TestSetupWithoutHandshake {
-    implicit def ec = system.dispatcher
+    implicit def ec: ExecutionContext = system.dispatcher
 
     private val framesOut: Http2FrameProbe = Http2FrameProbe()
     private val toNet = framesOut.plainDataProbe
diff --git a/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/ProtocolSwitchSpec.scala b/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/ProtocolSwitchSpec.scala
index 6a90250af..3154b09df 100644
--- a/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/ProtocolSwitchSpec.scala
+++ b/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/ProtocolSwitchSpec.scala
@@ -9,6 +9,7 @@ import akka.Done
 import akka.http.impl.engine.server.ServerTerminator
 import akka.http.scaladsl.Http
 import akka.stream.ActorMaterializer
+import akka.stream.Materializer
 import akka.stream.OverflowStrategy
 import akka.stream.QueueOfferResult.Enqueued
 import akka.stream.TLSProtocol._
@@ -22,10 +23,11 @@ import akka.testkit.AkkaSpec
 import org.scalatest.exceptions.TestFailedException
 import org.scalatest.time.{ Milliseconds, Seconds, Span }
 
+import scala.concurrent.ExecutionContext
 import scala.concurrent.duration.FiniteDuration
 
 class ProtocolSwitchSpec extends AkkaSpec {
-  implicit val mat = ActorMaterializer()
+  implicit val mat: Materializer = ActorMaterializer()
 
   override implicit val patience: PatienceConfig = PatienceConfig(timeout = Span(2, Seconds), interval = Span(50, Milliseconds))
 
diff --git a/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/RequestParsingSpec.scala b/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/RequestParsingSpec.scala
index 2f697530f..4ca9f1693 100644
--- a/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/RequestParsingSpec.scala
+++ b/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/RequestParsingSpec.scala
@@ -95,7 +95,7 @@ class RequestParsingSpec extends AkkaSpecWithMaterializer with Inside with Inspe
           ":scheme" -> "https",
           ":path" -> "/"
         )
-        forAll(0 until pseudoHeaders.length) { insertPoint: Int =>
+        forAll(pseudoHeaders.indices: Seq[Int]) { (insertPoint: Int) =>
           // Insert the Foo header so it occurs before at least one pseudo-header
           val (before, after) = pseudoHeaders.splitAt(insertPoint)
           val modified = before ++ Vector("Foo" -> "bar") ++ after
@@ -151,7 +151,7 @@ class RequestParsingSpec extends AkkaSpecWithMaterializer with Inside with Inspe
 
       "parse the ':method' pseudo-header correctly" in {
         val methods = Seq("GET", "POST", "DELETE", "OPTIONS")
-        forAll(methods) { method: String =>
+        forAll(methods) { (method: String) =>
           val request: HttpRequest = parse(
             keyValuePairs = Vector(
               ":method" -> method,
@@ -174,7 +174,7 @@ class RequestParsingSpec extends AkkaSpecWithMaterializer with Inside with Inspe
         // We're restricted in what we can test because the HttpRequest class
         // can't be constructed with any other schemes.
         val schemes = Seq("http", "https", "ws", "wss")
-        forAll(schemes) { scheme: String =>
+        forAll(schemes) { (scheme: String) =>
           val request: HttpRequest = parse(
             keyValuePairs = Vector(
               ":method" -> "POST",
@@ -245,8 +245,8 @@ class RequestParsingSpec extends AkkaSpecWithMaterializer with Inside with Inspe
           "cnn.example.com&story=breaking_news@10.0.0.1"
         )
         val schemes = Seq("http", "https")
-        forAll(schemes) { scheme: String =>
-          forAll(authorities) { authority: String =>
+        forAll(schemes) { (scheme: String) =>
+          forAll(authorities) { (authority: String) =>
             val exception = the[Exception] thrownBy (parse(
               keyValuePairs = Vector(
                 ":method" -> "POST",
@@ -332,7 +332,7 @@ class RequestParsingSpec extends AkkaSpecWithMaterializer with Inside with Inspe
             "?", "&", "=", "#", ":", "?", "#", "[", "]", "@", " ",
             "http://localhost/foo"
           )
-          forAll(invalidAbsolutePaths) { absPath: String =>
+          forAll(invalidAbsolutePaths) { (absPath: String) =>
             val exception = the[ParsingException] thrownBy (parsePath(absPath))
             exception.getMessage should include("http2-path-pseudo-header")
           }
@@ -343,7 +343,7 @@ class RequestParsingSpec extends AkkaSpecWithMaterializer with Inside with Inspe
             // Illegal for path-absolute in RFC3986 to start with multiple slashes
             "//", "//x"
           )
-          forAll(invalidAbsolutePaths) { absPath: String =>
+          forAll(invalidAbsolutePaths) { (absPath: String) =>
             val exception = the[ParsingException] thrownBy (parsePath(absPath, uriParsingMode = Uri.ParsingMode.Strict))
             exception.getMessage should include("http2-path-pseudo-header")
           }
@@ -375,7 +375,7 @@ class RequestParsingSpec extends AkkaSpecWithMaterializer with Inside with Inspe
                   // How form-encoded query strings are parsed is not strictly part of the HTTP/2 and URI RFCs,
                   // but lets do a quick sanity check to ensure that form-encoded query strings are correctly
                   // parsed into values further up the parsing stack.
-                  optParsedQuery.foreach { expectedParsedQuery: Uri.Query =>
+                  optParsedQuery.foreach { (expectedParsedQuery: Uri.Query) =>
                     uri.query() should contain theSameElementsAs (expectedParsedQuery)
                   }
               }
@@ -388,7 +388,7 @@ class RequestParsingSpec extends AkkaSpecWithMaterializer with Inside with Inspe
           )
           forAll(absolutePaths.take(3)) {
             case (inputPath, _) =>
-              forAll(invalidQueries) { query: String =>
+              forAll(invalidQueries) { (query: String) =>
                 shouldThrowMalformedRequest(parsePath(inputPath + "?" + query, uriParsingMode = Uri.ParsingMode.Strict))
               }
           }
@@ -414,7 +414,7 @@ class RequestParsingSpec extends AkkaSpecWithMaterializer with Inside with Inspe
 
       "reject empty ':path' pseudo-headers for http and https" in pendingUntilFixed {
         val schemes = Seq("http", "https")
-        forAll(schemes) { scheme: String =>
+        forAll(schemes) { (scheme: String) =>
           shouldThrowMalformedRequest(parse(
             keyValuePairs = Vector(
               ":method" -> "POST",
@@ -440,7 +440,7 @@ class RequestParsingSpec extends AkkaSpecWithMaterializer with Inside with Inspe
 
       "reject requests without a mandatory pseudo-headers" in {
         val mandatoryPseudoHeaders = Seq(":method", ":scheme", ":path")
-        forAll(mandatoryPseudoHeaders) { name: String =>
+        forAll(mandatoryPseudoHeaders) { (name: String) =>
           val thrown = shouldThrowMalformedRequest(parse(
             keyValuePairs = Vector(
               ":scheme" -> "https",
diff --git a/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/TelemetrySpiSpec.scala b/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/TelemetrySpiSpec.scala
index addeeca87..5ef116628 100644
--- a/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/TelemetrySpiSpec.scala
+++ b/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/TelemetrySpiSpec.scala
@@ -211,7 +211,8 @@ abstract class TelemetrySpiSpec(useTls: Boolean) extends AkkaSpecWithMaterialize
       val connId = telemetryProbe.expectMsgType[ConnectionId]
       // ... and a request flies in via _that_ connection.
       telemetryProbe.expectMsg("request-seen")
-      telemetryProbe.expectMsgType[ConnectionId] should ===(connId)
+      val requestConnId = telemetryProbe.expectMsgType[ConnectionId]
+      requestConnId should ===(connId)
 
       // The server sends the response...
       telemetryProbe.expectMsg("response-seen")
diff --git a/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/WithInPendingUntilFixed.scala b/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/WithInPendingUntilFixed.scala
deleted file mode 100644
index bc568740d..000000000
--- a/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/WithInPendingUntilFixed.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright (C) 2009-2022 Lightbend Inc. <https://www.lightbend.com>
- */
-
-package akka.http.impl.engine.http2
-
-import org.scalactic.source
-import org.scalatest.wordspec.AnyWordSpecLike
-
-/** Adds `"test" inPendingUntilFixed {...}` which is equivalent to `"test" in pendingUntilFixed({...})` */
-trait WithInPendingUntilFixed extends AnyWordSpecLike {
-  implicit class InPendingUntilFixed(val str: String) {
-    def inPendingUntilFixed(f: => Any /* Assertion */ )(implicit pos: source.Position): Unit =
-      str.in(pendingUntilFixed(f))(pos)
-  }
-}
diff --git a/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/WithPriorKnowledgeSpec.scala b/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/WithPriorKnowledgeSpec.scala
index 4aa6e980f..af1c5df90 100644
--- a/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/WithPriorKnowledgeSpec.scala
+++ b/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/WithPriorKnowledgeSpec.scala
@@ -40,7 +40,7 @@ class WithPriorKnowledgeSpec extends AkkaSpecWithMaterializer("""
       val source =
         Source.queue[String](1000, OverflowStrategy.fail)
           .map(str => ByteString(Base64.getDecoder.decode(str)))
-          .via(Tcp().outgoingConnection(host, port))
+          .via(Tcp(system).outgoingConnection(host, port))
           .toMat(fromServer.sink)(Keep.left)
           .run()
 
diff --git a/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/framing/Http2FramingSpec.scala b/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/framing/Http2FramingSpec.scala
index e2571ccda..308006f9c 100644
--- a/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/framing/Http2FramingSpec.scala
+++ b/akka-http2-support/src/test/scala/akka/http/impl/engine/http2/framing/Http2FramingSpec.scala
@@ -494,7 +494,7 @@ class Http2FramingSpec extends AkkaSpecWithMaterializer {
     }
 
   private def parseToEvents(bytes: Seq[ByteString]): immutable.Seq[FrameEvent] =
-    Source(bytes.toVector).via(new Http2FrameParsing(shouldReadPreface = false, Logging(system, getClass))).runWith(Sink.seq)
+    Source(bytes.toVector).via(new Http2FrameParsing(shouldReadPreface = false, Logging(system, classOf[Http2FramingSpec]))).runWith(Sink.seq)
       .awaitResult(1.second.dilated)
   private def renderToByteString(events: immutable.Seq[FrameEvent]): ByteString =
     Source(events).map(FrameRenderer.render).runFold(ByteString.empty)(_ ++ _)
diff --git a/akka-http2-support/src/test/scala/akka/http/scaladsl/Http2ServerTest.scala b/akka-http2-support/src/test/scala/akka/http/scaladsl/Http2ServerTest.scala
index fe3a0b6d6..aceb8ad6f 100644
--- a/akka-http2-support/src/test/scala/akka/http/scaladsl/Http2ServerTest.scala
+++ b/akka-http2-support/src/test/scala/akka/http/scaladsl/Http2ServerTest.scala
@@ -35,7 +35,7 @@ object Http2ServerTest extends App {
     akka.actor.default-dispatcher.fork-join-executor.parallelism-max=8
     akka.http.server.preview.enable-http2 = true
                                                    """)
-  implicit val system = ActorSystem("ServerTest", testConf)
+  implicit val system: ActorSystem = ActorSystem("ServerTest", testConf)
   implicit val ec: ExecutionContext = system.dispatcher
 
   def slowDown[T](millis: Int): T => Future[T] = { t =>
diff --git a/build.sbt b/build.sbt
index ffc3f6108..7d5c911ff 100644
--- a/build.sbt
+++ b/build.sbt
@@ -233,7 +233,6 @@ lazy val http2Support = project("akka-http2-support")
   .enablePlugins(BootstrapGenjavadoc)
   .enablePlugins(ReproducibleBuildsPlugin)
   .disablePlugins(MimaPlugin) // experimental module still
-  .enablePlugins(NoScala3) // FIXME
 
 lazy val httpTestkit = project("akka-http-testkit")
   .settings(commonSettings)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org