Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove more uses of ActorMaterializer #363

Merged
merged 2 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" - {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand All @@ -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" - {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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," - {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand Down Expand Up @@ -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]()
Expand Down Expand Up @@ -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]()

Expand Down Expand Up @@ -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]()

Expand Down Expand Up @@ -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]()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand All @@ -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]) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand All @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
Loading