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

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


The following commit(s) were added to refs/heads/main by this push:
     new 9c1185514 remove more uses of ActorMaterializer (#363)
9c1185514 is described below

commit 9c1185514fb593bda6727e99942b105fa3a1de75
Author: PJ Fanning <[email protected]>
AuthorDate: Sun Nov 12 09:49:37 2023 +0100

    remove more uses of ActorMaterializer (#363)
    
    * remove more uses of ActorMaterializer
    
    Update HttpServerSpec.scala
    
    * Update HttpServerSpec.scala
---
 .../pekko/http/impl/engine/parsing/RequestParserSpec.scala |  2 --
 .../http/impl/engine/rendering/RequestRendererSpec.scala   |  3 ---
 .../http/impl/engine/rendering/ResponseRendererSpec.scala  |  2 --
 .../pekko/http/impl/engine/server/HttpServerSpec.scala     | 14 ++++----------
 .../http/impl/engine/server/PrepareRequestsSpec.scala      | 10 +---------
 .../pekko/http/impl/engine/ws/EchoTestClientApp.scala      |  2 --
 .../pekko/http/impl/engine/ws/WSClientAutobahnTest.scala   |  2 --
 .../pekko/http/impl/engine/ws/WSServerAutobahnTest.scala   |  2 --
 .../apache/pekko/http/impl/util/One2OneBidiFlowSpec.scala  |  3 ---
 .../org/apache/pekko/http/impl/util/StreamUtilsSpec.scala  |  3 +--
 .../scala/org/apache/pekko/http/scaladsl/ClientSpec.scala  |  2 --
 .../scala/org/apache/pekko/http/scaladsl/TestClient.scala  |  3 +--
 .../pekko/http/scaladsl/TightRequestTimeoutSpec.scala      |  3 +--
 13 files changed, 8 insertions(+), 43 deletions(-)

diff --git 
a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/parsing/RequestParserSpec.scala
 
b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/parsing/RequestParserSpec.scala
index 56bb17b95..7b6d8079c 100644
--- 
a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/parsing/RequestParserSpec.scala
+++ 
b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/parsing/RequestParserSpec.scala
@@ -21,7 +21,6 @@ import scala.concurrent.duration._
 import com.typesafe.config.{ Config, ConfigFactory }
 import pekko.util.ByteString
 import pekko.actor.ActorSystem
-import pekko.stream.ActorMaterializer
 import pekko.stream.scaladsl._
 import pekko.stream.TLSProtocol._
 import org.scalatest.matchers.Matcher
@@ -59,7 +58,6 @@ abstract class RequestParserSpec(mode: String, newLine: 
String) extends AnyFreeS
   import system.dispatcher
 
   val BOLT = HttpMethod.custom("BOLT", safe = false, idempotent = true, 
requestEntityAcceptance = Expected)
-  implicit val materializer: ActorMaterializer = ActorMaterializer()
 
   s"The request parsing logic should (mode: $mode)" - {
     "properly parse a request" - {
diff --git 
a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/rendering/RequestRendererSpec.scala
 
b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/rendering/RequestRendererSpec.scala
index 6afc78121..94bc8ba6a 100644
--- 
a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/rendering/RequestRendererSpec.scala
+++ 
b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/rendering/RequestRendererSpec.scala
@@ -28,7 +28,6 @@ import pekko.http.scaladsl.model._
 import pekko.http.scaladsl.model.headers._
 import pekko.http.impl.util._
 import pekko.stream.scaladsl._
-import pekko.stream.ActorMaterializer
 import HttpEntity._
 import HttpMethods._
 import pekko.testkit._
@@ -42,8 +41,6 @@ class RequestRendererSpec extends AnyFreeSpec with Matchers 
with BeforeAndAfterA
   implicit val system: ActorSystem = ActorSystem(getClass.getSimpleName, 
testConf)
   import system.dispatcher
 
-  implicit val materializer: ActorMaterializer = ActorMaterializer()
-
   "The request preparation logic should" - {
     "properly render an unchunked" - {
 
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 b47d57cf6..6f3af899f 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
@@ -27,7 +27,6 @@ import pekko.http.scaladsl.model.headers._
 import pekko.http.impl.util._
 import pekko.util.ByteString
 import pekko.stream.scaladsl._
-import pekko.stream.ActorMaterializer
 import HttpEntity._
 import pekko.http.impl.engine.rendering.ResponseRenderingContext.CloseRequested
 import pekko.http.impl.util.Rendering.CrLf
@@ -44,7 +43,6 @@ class ResponseRendererSpec extends AnyFreeSpec with Matchers 
with BeforeAndAfter
   implicit val system: ActorSystem = ActorSystem(getClass.getSimpleName, 
testConf)
 
   val ServerOnTheMove = StatusCodes.custom(330, "Server on the move")
-  implicit val materializer: ActorMaterializer = ActorMaterializer()
 
   "The response preparation logic should properly render" - {
     "a response with no body," - {
diff --git 
a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/server/HttpServerSpec.scala
 
b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/server/HttpServerSpec.scala
index a6ee05a83..893973e8d 100644
--- 
a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/server/HttpServerSpec.scala
+++ 
b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/server/HttpServerSpec.scala
@@ -13,10 +13,6 @@
 
 package org.apache.pekko.http.impl.engine.server
 
-import scala.annotation.nowarn
-
-import java.net.{ InetAddress, InetSocketAddress }
-
 import org.apache.pekko
 import pekko.actor.ActorSystem
 import pekko.event.LoggingAdapter
@@ -33,17 +29,15 @@ import pekko.http.scaladsl.settings.ServerSettings
 import pekko.stream.scaladsl._
 import pekko.stream.testkit.Utils.assertAllStagesStopped
 import pekko.stream.testkit._
-import pekko.stream.{ ActorMaterializer, Materializer }
-import pekko.stream.Attributes
-import pekko.stream.Outlet
-import pekko.stream.SourceShape
+import pekko.stream.{ Attributes, Materializer, Outlet, SourceShape }
 import pekko.stream.stage.GraphStage
 import pekko.stream.stage.GraphStageLogic
 import pekko.testkit._
 import pekko.util.ByteString
 import org.scalatest.Inside
 
-import scala.annotation.tailrec
+import java.net.{ InetAddress, InetSocketAddress }
+import scala.annotation.{ nowarn, tailrec }
 import scala.concurrent.duration._
 import scala.reflect.ClassTag
 import scala.util.Random
@@ -60,7 +54,7 @@ class HttpServerSpec extends PekkoSpec(
      pekko.http.server.log-unencrypted-network-bytes = 100
      pekko.http.server.request-timeout = infinite
   """) with Inside with WithLogCapturing { spec =>
-  implicit val materializer: ActorMaterializer = ActorMaterializer()
+  implicit val materializer: Materializer = Materializer(system)
 
   "The server implementation" should {
     "deliver an empty request as soon as all headers are received" in 
assertAllStagesStopped(new TestSetup {
diff --git 
a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/server/PrepareRequestsSpec.scala
 
b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/server/PrepareRequestsSpec.scala
index 252b72696..fd7841dad 100644
--- 
a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/server/PrepareRequestsSpec.scala
+++ 
b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/server/PrepareRequestsSpec.scala
@@ -24,7 +24,7 @@ import pekko.http.impl.engine.parsing.ParserOutput.{
 import pekko.http.impl.engine.server.HttpServerBluePrint.PrepareRequests
 import pekko.http.scaladsl.model._
 import pekko.http.scaladsl.settings.ServerSettings
-import pekko.stream.{ ActorMaterializer, Attributes }
+import pekko.stream.Attributes
 import pekko.stream.scaladsl.{ Flow, Sink, Source }
 import pekko.stream.testkit.{ TestPublisher, TestSubscriber }
 import pekko.testkit._
@@ -70,7 +70,6 @@ class PrepareRequestsSpec extends PekkoSpec {
   "The PrepareRequest stage" should {
 
     "not fail when there is demand from both streamed entity consumption and 
regular flow" in {
-      implicit val materializer: ActorMaterializer = ActorMaterializer()
       // covers bug #19623 where a reply before the streamed
       // body has been consumed causes pull/push twice
       val inProbe = TestPublisher.manualProbe[ParserOutput.RequestOutput]()
@@ -130,8 +129,6 @@ class PrepareRequestsSpec extends PekkoSpec {
     }
 
     "not complete running entity stream when upstream cancels" in {
-      implicit val materializer: ActorMaterializer = ActorMaterializer()
-
       val inProbe = TestPublisher.manualProbe[ParserOutput.RequestOutput]()
       val upstreamProbe = TestSubscriber.manualProbe[HttpRequest]()
 
@@ -180,9 +177,6 @@ class PrepareRequestsSpec extends PekkoSpec {
     }
 
     "complete stage if chunked stream is completed without reaching end of 
chunks" in {
-      // a bit unsure about this, but to document the assumption
-      implicit val materializer: ActorMaterializer = ActorMaterializer()
-
       val inProbe = TestPublisher.manualProbe[ParserOutput.RequestOutput]()
       val upstreamProbe = TestSubscriber.manualProbe[HttpRequest]()
 
@@ -222,8 +216,6 @@ class PrepareRequestsSpec extends PekkoSpec {
     }
 
     "cancel the stage when the entity stream is canceled" in {
-      implicit val materializer: ActorMaterializer = ActorMaterializer()
-
       val inProbe = TestPublisher.manualProbe[ParserOutput.RequestOutput]()
       val upstreamProbe = TestSubscriber.manualProbe[HttpRequest]()
 
diff --git 
a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/EchoTestClientApp.scala
 
b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/EchoTestClientApp.scala
index 8d9c22b17..de81c7678 100644
--- 
a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/EchoTestClientApp.scala
+++ 
b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/EchoTestClientApp.scala
@@ -21,7 +21,6 @@ import scala.concurrent.duration._
 import pekko.actor.ActorSystem
 import pekko.http.scaladsl.Http
 import pekko.http.scaladsl.model.ws.{ BinaryMessage, Message, TextMessage }
-import pekko.stream.ActorMaterializer
 import pekko.stream.scaladsl._
 import pekko.util.ByteString
 
@@ -34,7 +33,6 @@ import scala.util.{ Failure, Success }
 object EchoTestClientApp extends App {
   implicit val system: ActorSystem = ActorSystem()
   import system.dispatcher
-  implicit val materializer: ActorMaterializer = ActorMaterializer()
 
   def delayedCompletion(delay: FiniteDuration): Source[Nothing, NotUsed] =
     Source.single(1)
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 069562e18..24dc9f08e 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
@@ -20,7 +20,6 @@ import scala.concurrent.Future
 import scala.util.{ Failure, Success, Try }
 import spray.json._
 import pekko.actor.ActorSystem
-import pekko.stream.ActorMaterializer
 import pekko.stream.scaladsl._
 import pekko.http.scaladsl.Http
 import pekko.http.scaladsl.model.Uri
@@ -29,7 +28,6 @@ import pekko.http.scaladsl.model.ws._
 object WSClientAutobahnTest extends App {
   implicit val system: ActorSystem = ActorSystem()
   import system.dispatcher
-  implicit val materializer: ActorMaterializer = ActorMaterializer()
 
   val Agent = "pekko-http"
   val Parallelism = 4
diff --git 
a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/WSServerAutobahnTest.scala
 
b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/WSServerAutobahnTest.scala
index feb373b81..8fa78f7fc 100644
--- 
a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/WSServerAutobahnTest.scala
+++ 
b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/WSServerAutobahnTest.scala
@@ -24,14 +24,12 @@ import pekko.http.scaladsl.model._
 import pekko.http.scaladsl.model.AttributeKeys.webSocketUpgrade
 import pekko.http.scaladsl.model.HttpMethods._
 import pekko.http.scaladsl.model.ws.Message
-import pekko.stream.ActorMaterializer
 import pekko.stream.scaladsl.Flow
 
 import scala.io.StdIn
 
 object WSServerAutobahnTest extends App {
   implicit val system: ActorSystem = ActorSystem("WSServerTest")
-  implicit val fm: ActorMaterializer = ActorMaterializer()
 
   val host = System.getProperty("pekko.ws-host", "127.0.0.1")
   val port = System.getProperty("pekko.ws-port", "9001").toInt
diff --git 
a/http-core/src/test/scala/org/apache/pekko/http/impl/util/One2OneBidiFlowSpec.scala
 
b/http-core/src/test/scala/org/apache/pekko/http/impl/util/One2OneBidiFlowSpec.scala
index 83fd068ff..d6c2976fe 100644
--- 
a/http-core/src/test/scala/org/apache/pekko/http/impl/util/One2OneBidiFlowSpec.scala
+++ 
b/http-core/src/test/scala/org/apache/pekko/http/impl/util/One2OneBidiFlowSpec.scala
@@ -17,7 +17,6 @@ import java.util.concurrent.atomic.AtomicInteger
 
 import org.apache.pekko
 import pekko.NotUsed
-import pekko.stream.{ ActorMaterializer, Materializer }
 import pekko.stream.scaladsl.{ Flow, Keep, Sink, Source }
 import pekko.stream.testkit.Utils._
 import pekko.stream.testkit._
@@ -28,8 +27,6 @@ import pekko.testkit._
 import org.scalatest.concurrent.Eventually
 
 class One2OneBidiFlowSpec extends PekkoSpec with Eventually {
-  implicit val materializer: Materializer = ActorMaterializer()
-
   "A One2OneBidiFlow" must {
 
     def test(flow: Flow[Int, Int, NotUsed]) =
diff --git 
a/http-core/src/test/scala/org/apache/pekko/http/impl/util/StreamUtilsSpec.scala
 
b/http-core/src/test/scala/org/apache/pekko/http/impl/util/StreamUtilsSpec.scala
index ff6eed9f3..49c3a4f74 100644
--- 
a/http-core/src/test/scala/org/apache/pekko/http/impl/util/StreamUtilsSpec.scala
+++ 
b/http-core/src/test/scala/org/apache/pekko/http/impl/util/StreamUtilsSpec.scala
@@ -14,7 +14,7 @@
 package org.apache.pekko.http.impl.util
 
 import org.apache.pekko
-import pekko.stream.{ ActorMaterializer, Attributes, Materializer }
+import pekko.stream.Attributes
 import pekko.stream.scaladsl.{ Sink, Source }
 import pekko.util.ByteString
 import pekko.testkit._
@@ -24,7 +24,6 @@ import scala.concurrent.duration._
 import scala.util.Failure
 
 class StreamUtilsSpec extends PekkoSpec with ScalaFutures {
-  implicit val materializer: Materializer = ActorMaterializer()
 
   "captureTermination" should {
     "signal completion" when {
diff --git 
a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/ClientSpec.scala 
b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/ClientSpec.scala
index 98adcaa49..bf363e2c9 100644
--- a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/ClientSpec.scala
+++ b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/ClientSpec.scala
@@ -17,7 +17,6 @@ import org.apache.pekko
 import pekko.actor.ActorSystem
 import pekko.http.scaladsl.model._
 import pekko.http.scaladsl.model.HttpMethods._
-import pekko.stream.ActorMaterializer
 import com.typesafe.config.{ Config, ConfigFactory }
 import scala.concurrent.duration._
 import scala.concurrent.Await
@@ -35,7 +34,6 @@ class ClientSpec extends AnyWordSpec with Matchers with 
BeforeAndAfterAll {
     pekko.log-dead-letters = OFF
     pekko.http.server.request-timeout = infinite""")
   implicit val system: ActorSystem = ActorSystem(getClass.getSimpleName, 
testConf)
-  implicit val materializer: ActorMaterializer = ActorMaterializer()
 
   override def afterAll() = TestKit.shutdownActorSystem(system)
 
diff --git 
a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/TestClient.scala 
b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/TestClient.scala
index 3fdd44114..56f6fa6e1 100644
--- a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/TestClient.scala
+++ b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/TestClient.scala
@@ -21,7 +21,7 @@ import com.typesafe.config.{ Config, ConfigFactory }
 import scala.util.{ Failure, Success }
 import org.apache.pekko
 import pekko.actor.{ ActorSystem, UnhandledMessage }
-import pekko.stream.{ ActorMaterializer, IOResult }
+import pekko.stream.IOResult
 import pekko.stream.scaladsl.{ FileIO, Sink, Source }
 import pekko.http.scaladsl.model._
 import pekko.http.impl.util._
@@ -36,7 +36,6 @@ object TestClient extends App {
     pekko.log-dead-letters = off
     pekko.io.tcp.trace-logging = off""")
   implicit val system: ActorSystem = ActorSystem("ServerTest", testConf)
-  implicit val fm: ActorMaterializer = ActorMaterializer()
   import system.dispatcher
 
   installEventStreamLoggerFor[UnhandledMessage]
diff --git 
a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/TightRequestTimeoutSpec.scala
 
b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/TightRequestTimeoutSpec.scala
index 8761b13d7..852e179da 100644
--- 
a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/TightRequestTimeoutSpec.scala
+++ 
b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/TightRequestTimeoutSpec.scala
@@ -18,7 +18,7 @@ import pekko.actor.ActorSystem
 import pekko.event.Logging
 import pekko.http.scaladsl.model._
 import pekko.stream.scaladsl._
-import pekko.stream.{ ActorMaterializer, OverflowStrategy }
+import pekko.stream.OverflowStrategy
 import com.typesafe.config.{ Config, ConfigFactory }
 import org.scalatest.concurrent.ScalaFutures
 import org.scalatest.BeforeAndAfterAll
@@ -37,7 +37,6 @@ class TightRequestTimeoutSpec extends AnyWordSpec with 
Matchers with BeforeAndAf
     pekko.http.server.request-timeout = 10ms""")
 
   implicit val system: ActorSystem = ActorSystem(getClass.getSimpleName, 
testConf)
-  implicit val materializer: ActorMaterializer = ActorMaterializer()
   implicit val patience: PatienceConfig = PatienceConfig(3.seconds.dilated)
 
   override def afterAll() = TestKit.shutdownActorSystem(system)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to