From 87f55da5817b20be224b96d87e984bdfbf883f79 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Mon, 30 Oct 2023 09:36:31 +0000 Subject: [PATCH] try to remove some uses of ActorMaterializer (#347) * try to remove some uses of ActorMaterializer * compile issue * try to fix tests * more changes * Update PekkoHttp1020MigrationSpec.scala --- .../javadsl/ComposeDirectivesExampleTest.java | 6 ----- .../java/docs/http/javadsl/Http2Test.java | 3 --- .../java/docs/http/javadsl/UnmarshalTest.java | 5 ----- .../javadsl/WebSocketClientExampleTest.java | 15 ++++++------- .../server/HttpServerExampleDocTest.java | 22 +++++++------------ .../server/PekkoHttp1020MigrationExample.java | 3 +-- .../javadsl/server/WebSocketCoreExample.java | 1 - .../BasicDirectivesExamplesTest.java | 9 -------- .../server/PekkoHttp1020MigrationSpec.scala | 2 -- .../impl/engine/ConnectionPoolBenchmark.scala | 3 --- .../impl/engine/HttpEntityBenchmark.scala | 5 +---- .../engine/ServerProcessingBenchmark.scala | 4 +--- .../StreamServerProcessingBenchmark.scala | 3 --- .../http2/H2ClientServerBenchmark.scala | 3 --- .../http2/H2ServerProcessingBenchmark.scala | 3 --- .../sse/LineParserBenchmark.scala | 2 -- .../impl/engine/client/PoolInterface.scala | 3 +-- .../http/scaladsl/model/HttpEntity.scala | 2 +- .../org/apache/pekko/http/JavaTestServer.java | 3 --- .../GracefulTerminationCompileTest.java | 2 -- .../http/javadsl/WSEchoTestClientApp.java | 3 +-- .../http/HttpModelIntegrationSpec.scala | 3 --- .../engine/client/PrepareResponseSpec.scala | 12 +--------- .../client/ResponseParsingMergeSpec.scala | 4 +--- .../marshallers/jackson/JacksonTest.java | 8 ------- .../sprayjson/SprayJsonSupportSpec.scala | 2 -- .../examples/petstore/PetStoreExample.java | 2 -- .../sse/EventStreamUnmarshallingTest.java | 6 +---- .../http/scaladsl/CustomMediaTypesSpec.scala | 3 --- .../pekko/http/scaladsl/FormDataSpec.scala | 2 -- .../http/scaladsl/TestSingleRequest.scala | 2 -- .../scaladsl/coding/CodecSpecSupport.scala | 2 -- .../marshalling/MarshallingSpec.scala | 2 -- .../scaladsl/server/ConnectionTestApp.scala | 3 +-- ...ntLeakActorsOnFailingConnectionSpecs.scala | 5 ++--- .../http/scaladsl/server/SizeLimitSpec.scala | 2 -- .../http/scaladsl/server/TcpLeakApp.scala | 3 +-- .../http/scaladsl/server/TestServer.scala | 2 -- .../unmarshalling/UnmarshallingSpec.scala | 2 -- .../sse/BaseUnmarshallingSpec.scala | 4 ---- .../pekko/http/javadsl/server/HttpApp.java | 2 -- .../engine/http2/H2SpecIntegrationSpec.scala | 2 -- .../engine/http2/ProtocolSwitchSpec.scala | 4 ---- 43 files changed, 28 insertions(+), 151 deletions(-) diff --git a/docs/src/test/java/docs/http/javadsl/ComposeDirectivesExampleTest.java b/docs/src/test/java/docs/http/javadsl/ComposeDirectivesExampleTest.java index 223637920..ca8e5f788 100644 --- a/docs/src/test/java/docs/http/javadsl/ComposeDirectivesExampleTest.java +++ b/docs/src/test/java/docs/http/javadsl/ComposeDirectivesExampleTest.java @@ -13,18 +13,12 @@ package docs.http.javadsl; -import org.apache.pekko.NotUsed; import org.apache.pekko.actor.ActorSystem; -import org.apache.pekko.http.javadsl.ConnectHttp; import org.apache.pekko.http.javadsl.Http; import org.apache.pekko.http.javadsl.ServerBinding; -import org.apache.pekko.http.javadsl.model.HttpRequest; -import org.apache.pekko.http.javadsl.model.HttpResponse; import org.apache.pekko.http.javadsl.server.AllDirectives; import org.apache.pekko.http.javadsl.server.PathMatcher1; import org.apache.pekko.http.javadsl.server.Route; -import org.apache.pekko.stream.ActorMaterializer; -import org.apache.pekko.stream.javadsl.Flow; import static org.apache.pekko.http.javadsl.common.PartialApplication.*; import static org.apache.pekko.http.javadsl.server.PathMatchers.*; diff --git a/docs/src/test/java/docs/http/javadsl/Http2Test.java b/docs/src/test/java/docs/http/javadsl/Http2Test.java index 6892dad64..0dbd941c7 100644 --- a/docs/src/test/java/docs/http/javadsl/Http2Test.java +++ b/docs/src/test/java/docs/http/javadsl/Http2Test.java @@ -27,8 +27,6 @@ import org.apache.pekko.http.javadsl.model.HttpRequest; import org.apache.pekko.http.javadsl.model.HttpResponse; import org.apache.pekko.japi.function.Function; -import org.apache.pekko.stream.ActorMaterializer; -import org.apache.pekko.stream.Materializer; // #bindAndHandleSecure // #bindAndHandlePlain @@ -46,7 +44,6 @@ void testBindAndHandleAsync() { Function> asyncHandler = r -> CompletableFuture.completedFuture(HttpResponse.create()); ActorSystem system = ActorSystem.create(); - Materializer materializer = ActorMaterializer.create(system); HttpsConnectionContext httpsConnectionContext = null; // #bindAndHandleSecure diff --git a/docs/src/test/java/docs/http/javadsl/UnmarshalTest.java b/docs/src/test/java/docs/http/javadsl/UnmarshalTest.java index e8fe06a42..b58c32acc 100644 --- a/docs/src/test/java/docs/http/javadsl/UnmarshalTest.java +++ b/docs/src/test/java/docs/http/javadsl/UnmarshalTest.java @@ -16,15 +16,10 @@ import static org.junit.Assert.assertEquals; import org.apache.pekko.http.javadsl.testkit.JUnitRouteTest; -import org.apache.pekko.util.ByteString; -import org.apache.pekko.stream.ActorMaterializer; -import org.apache.pekko.stream.Materializer; import org.junit.Test; // #imports -import org.apache.pekko.http.javadsl.model.*; import org.apache.pekko.http.javadsl.unmarshalling.StringUnmarshallers; -import org.apache.pekko.http.javadsl.unmarshalling.Unmarshaller; import java.util.concurrent.CompletionStage; import java.util.concurrent.TimeUnit; diff --git a/docs/src/test/java/docs/http/javadsl/WebSocketClientExampleTest.java b/docs/src/test/java/docs/http/javadsl/WebSocketClientExampleTest.java index bacfd0a0a..034b542e8 100644 --- a/docs/src/test/java/docs/http/javadsl/WebSocketClientExampleTest.java +++ b/docs/src/test/java/docs/http/javadsl/WebSocketClientExampleTest.java @@ -27,7 +27,6 @@ import org.apache.pekko.http.javadsl.model.ws.WebSocketUpgradeResponse; import org.apache.pekko.http.javadsl.settings.ClientConnectionSettings; import org.apache.pekko.japi.Pair; -import org.apache.pekko.stream.ActorMaterializer; import org.apache.pekko.stream.Materializer; import org.apache.pekko.stream.javadsl.Flow; import org.apache.pekko.stream.javadsl.Keep; @@ -47,7 +46,7 @@ public class WebSocketClientExampleTest { public void testSingleWebSocketRequest() { // #single-WebSocket-request ActorSystem system = ActorSystem.create(); - Materializer materializer = ActorMaterializer.create(system); + Materializer materializer = Materializer.createMaterializer(system); Http http = Http.get(system); // print each incoming text message @@ -101,7 +100,7 @@ public void testSingleWebSocketRequest() { public void halfClosedWebSocketClosingExample() { final ActorSystem system = ActorSystem.create(); - final Materializer materializer = ActorMaterializer.create(system); + final Materializer materializer = Materializer.createMaterializer(system); final Http http = Http.get(system); // #half-closed-WebSocket-closing @@ -119,7 +118,7 @@ public void halfClosedWebSocketClosingExample() { public void halfClosedWebSocketWorkingExample() { final ActorSystem system = ActorSystem.create(); - final Materializer materializer = ActorMaterializer.create(system); + final Materializer materializer = Materializer.createMaterializer(system); final Http http = Http.get(system); // #half-closed-WebSocket-working @@ -141,7 +140,7 @@ public void halfClosedWebSocketWorkingExample() { public void halfClosedWebSocketFiniteWorkingExample() { final ActorSystem system = ActorSystem.create(); - final Materializer materializer = ActorMaterializer.create(system); + final Materializer materializer = Materializer.createMaterializer(system); final Http http = Http.get(system); // #half-closed-WebSocket-finite @@ -184,7 +183,7 @@ public void testAuthorizedSingleWebSocketRequest() { public void testWebSocketClientFlow() { // #WebSocket-client-flow ActorSystem system = ActorSystem.create(); - Materializer materializer = ActorMaterializer.create(system); + Materializer materializer = Materializer.createMaterializer(system); Http http = Http.get(system); // print each incoming text message @@ -240,7 +239,7 @@ public void testSingleWebSocketRequestWithHttpsProxyExample() { // #https-proxy-singleWebSocket-request-example final ActorSystem system = ActorSystem.create(); - final Materializer materializer = ActorMaterializer.create(system); + final Materializer materializer = Materializer.createMaterializer(system); final Flow flow = Flow.fromSinkAndSource( @@ -268,7 +267,7 @@ public void testSingleWebSocketRequestWithHttpsProxyExample() { public void testSingleWebSocketRequestWithHttpsProxyExampleWithAuth() { final ActorSystem system = ActorSystem.create(); - final Materializer materializer = ActorMaterializer.create(system); + final Materializer materializer = Materializer.createMaterializer(system); final Flow flow = Flow.fromSinkAndSource( diff --git a/docs/src/test/java/docs/http/javadsl/server/HttpServerExampleDocTest.java b/docs/src/test/java/docs/http/javadsl/server/HttpServerExampleDocTest.java index 91170b263..b662a168a 100644 --- a/docs/src/test/java/docs/http/javadsl/server/HttpServerExampleDocTest.java +++ b/docs/src/test/java/docs/http/javadsl/server/HttpServerExampleDocTest.java @@ -16,17 +16,14 @@ import org.apache.pekko.Done; import org.apache.pekko.NotUsed; import org.apache.pekko.actor.ActorSystem; -import org.apache.pekko.actor.CoordinatedShutdown; import org.apache.pekko.http.javadsl.*; import org.apache.pekko.http.javadsl.marshallers.jackson.Jackson; import org.apache.pekko.http.javadsl.model.*; import org.apache.pekko.http.javadsl.model.headers.Connection; -import org.apache.pekko.http.javadsl.server.AllDirectives; import org.apache.pekko.http.javadsl.server.Directives; import org.apache.pekko.http.javadsl.server.Route; import org.apache.pekko.http.javadsl.unmarshalling.Unmarshaller; import org.apache.pekko.japi.function.Function; -import org.apache.pekko.stream.ActorMaterializer; import org.apache.pekko.stream.IOResult; import org.apache.pekko.stream.Materializer; import org.apache.pekko.stream.javadsl.FileIO; @@ -51,7 +48,7 @@ public class HttpServerExampleDocTest { public static void bindingExample() throws Exception { // #binding-example ActorSystem system = ActorSystem.create(); - Materializer materializer = ActorMaterializer.create(system); + Materializer materializer = Materializer.createMaterializer(system); Source> serverSource = Http.get(system).bind(ConnectHttp.toHost("localhost", 8080)); @@ -73,7 +70,7 @@ public static void bindingExample() throws Exception { public static void bindingFailureExample() throws Exception { // #binding-failure-handling ActorSystem system = ActorSystem.create(); - Materializer materializer = ActorMaterializer.create(system); + Materializer materializer = Materializer.createMaterializer(system); Source> serverSource = Http.get(system).bind(ConnectHttp.toHost("localhost", 80)); @@ -101,7 +98,7 @@ public static void bindingFailureExample() throws Exception { public static void connectionSourceFailureExample() throws Exception { // #incoming-connections-source-failure-handling ActorSystem system = ActorSystem.create(); - Materializer materializer = ActorMaterializer.create(system); + Materializer materializer = Materializer.createMaterializer(system); Source> serverSource = Http.get(system).bind(ConnectHttp.toHost("localhost", 8080)); @@ -137,7 +134,7 @@ public static void connectionSourceFailureExample() throws Exception { public static void connectionStreamFailureExample() throws Exception { // #connection-stream-failure-handling ActorSystem system = ActorSystem.create(); - Materializer materializer = ActorMaterializer.create(system); + Materializer materializer = Materializer.createMaterializer(system); Source> serverSource = Http.get(system).bind(ConnectHttp.toHost("localhost", 8080)); @@ -186,7 +183,7 @@ public static void fullServerExample() throws Exception { // #full-server-example try { // #full-server-example - final Materializer materializer = ActorMaterializer.create(system); + final Materializer materializer = Materializer.createMaterializer(system); Source> serverSource = Http.get(system).bind(ConnectHttp.toHost("localhost", 8080)); @@ -265,7 +262,6 @@ class Bid { final ActorSystem system = ActorSystem.create(); final ExecutionContextExecutor dispatcher = system.dispatcher(); - final ActorMaterializer materializer = ActorMaterializer.create(system); final Unmarshaller asBid = Jackson.unmarshaller(Bid.class); @@ -287,7 +283,6 @@ void consumeEntityUsingRawDataBytes() { // #consume-raw-dataBytes final ActorSystem system = ActorSystem.create(); final ExecutionContextExecutor dispatcher = system.dispatcher(); - final ActorMaterializer materializer = ActorMaterializer.create(system); final Route s = put( @@ -302,7 +297,7 @@ void consumeEntityUsingRawDataBytes() { final CompletionStage res = bytes.runWith( FileIO.toPath(new File("/tmp/example.out").toPath()), - materializer); + system); return onComplete( () -> res, @@ -347,7 +342,6 @@ void discardEntityManuallyCloseConnections() { // #discard-close-connections final ActorSystem system = ActorSystem.create(); final ExecutionContextExecutor dispatcher = system.dispatcher(); - final ActorMaterializer materializer = ActorMaterializer.create(system); final Route s = put( @@ -364,7 +358,7 @@ void discardEntityManuallyCloseConnections() { // right away: bytes.runWith( Sink.cancelled(), - materializer); // "brutally" closes the connection + system); // "brutally" closes the connection // Closing connections, method 2 (graceful): // consider draining connection and replying with `Connection: @@ -381,7 +375,7 @@ void discardEntityManuallyCloseConnections() { public static void gracefulTerminationExample() throws Exception { // #graceful-termination ActorSystem system = ActorSystem.create(); - Materializer materializer = ActorMaterializer.create(system); + Materializer materializer = Materializer.createMaterializer(system); CompletionStage binding = Http.get(system) diff --git a/docs/src/test/java/docs/http/javadsl/server/PekkoHttp1020MigrationExample.java b/docs/src/test/java/docs/http/javadsl/server/PekkoHttp1020MigrationExample.java index c7726702e..ae52b8eec 100644 --- a/docs/src/test/java/docs/http/javadsl/server/PekkoHttp1020MigrationExample.java +++ b/docs/src/test/java/docs/http/javadsl/server/PekkoHttp1020MigrationExample.java @@ -18,7 +18,6 @@ import org.apache.pekko.http.javadsl.Http; import static org.apache.pekko.http.javadsl.server.Directives.*; import org.apache.pekko.http.javadsl.server.Route; -import org.apache.pekko.stream.ActorMaterializer; import org.apache.pekko.stream.Materializer; @SuppressWarnings("deprecation") @@ -29,7 +28,7 @@ public static void main(String[] args) { // only worked with classic actor system org.apache.pekko.actor.ActorSystem system = org.apache.pekko.actor.ActorSystem.create("TheSystem"); - Materializer mat = ActorMaterializer.create(system); + Materializer mat = Materializer.createMaterializer(system); Route route = get(() -> complete("Hello World!")); Http.get(system) .bindAndHandle(route.flow(system), ConnectHttp.toHost("localhost", 8080), mat); diff --git a/docs/src/test/java/docs/http/javadsl/server/WebSocketCoreExample.java b/docs/src/test/java/docs/http/javadsl/server/WebSocketCoreExample.java index b513e603a..5455fa1c6 100644 --- a/docs/src/test/java/docs/http/javadsl/server/WebSocketCoreExample.java +++ b/docs/src/test/java/docs/http/javadsl/server/WebSocketCoreExample.java @@ -35,7 +35,6 @@ import org.apache.pekko.japi.JavaPartialFunction; import org.apache.pekko.japi.function.Function; -import org.apache.pekko.stream.ActorMaterializer; import org.apache.pekko.stream.Materializer; import org.apache.pekko.stream.javadsl.Flow; import org.apache.pekko.stream.javadsl.Source; diff --git a/docs/src/test/java/docs/http/javadsl/server/directives/BasicDirectivesExamplesTest.java b/docs/src/test/java/docs/http/javadsl/server/directives/BasicDirectivesExamplesTest.java index 17632e3b0..01d6b2c3c 100644 --- a/docs/src/test/java/docs/http/javadsl/server/directives/BasicDirectivesExamplesTest.java +++ b/docs/src/test/java/docs/http/javadsl/server/directives/BasicDirectivesExamplesTest.java @@ -35,7 +35,6 @@ import org.apache.pekko.japi.pf.PFBuilder; import org.apache.pekko.stream.ActorMaterializer; import org.apache.pekko.stream.ActorMaterializerSettings; -import org.apache.pekko.stream.javadsl.FileIO; import org.apache.pekko.stream.javadsl.Sink; import org.apache.pekko.stream.javadsl.Source; import org.apache.pekko.util.ByteString; @@ -44,7 +43,6 @@ import scala.concurrent.ExecutionContextExecutor; import scala.concurrent.duration.FiniteDuration; -import java.nio.file.Paths; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; @@ -58,13 +56,6 @@ import java.util.function.Supplier; import java.util.stream.StreamSupport; -import static org.apache.pekko.http.javadsl.server.Directives.complete; -import static org.apache.pekko.http.javadsl.server.Directives.get; -import static org.apache.pekko.http.javadsl.server.Directives.onSuccess; -import static org.apache.pekko.http.javadsl.server.Directives.path; -import static org.apache.pekko.http.javadsl.server.Directives.pathPrefix; -import static org.apache.pekko.http.javadsl.server.Directives.post; - // #extract import static org.apache.pekko.http.javadsl.server.Directives.extract; diff --git a/docs/src/test/scala/docs/http/scaladsl/server/PekkoHttp1020MigrationSpec.scala b/docs/src/test/scala/docs/http/scaladsl/server/PekkoHttp1020MigrationSpec.scala index 9c2f65284..ae9debd61 100644 --- a/docs/src/test/scala/docs/http/scaladsl/server/PekkoHttp1020MigrationSpec.scala +++ b/docs/src/test/scala/docs/http/scaladsl/server/PekkoHttp1020MigrationSpec.scala @@ -16,7 +16,6 @@ package docs.http.scaladsl.server import org.apache.pekko.actor.typed.scaladsl.Behaviors import org.apache.pekko.http.scaladsl.Http import org.apache.pekko.http.scaladsl.server.Route -import org.apache.pekko.stream.{ ActorMaterializer, Materializer } import scala.annotation.nowarn @nowarn("msg=is deprecated") @@ -27,7 +26,6 @@ class PekkoHttp1020MigrationSpec { // #old-binding // only worked with classic actor system implicit val system = org.apache.pekko.actor.ActorSystem("TheSystem") - implicit val mat: Materializer = ActorMaterializer() val route: Route = get { complete("Hello world") diff --git a/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/ConnectionPoolBenchmark.scala b/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/ConnectionPoolBenchmark.scala index 5e4e147b9..b2f30f89d 100644 --- a/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/ConnectionPoolBenchmark.scala +++ b/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/ConnectionPoolBenchmark.scala @@ -24,7 +24,6 @@ import pekko.http.impl.util.enhanceString_ import pekko.http.scaladsl.model.HttpRequest import pekko.http.scaladsl.settings.{ ClientConnectionSettings, ConnectionPoolSettings } import pekko.http.scaladsl.{ ClientTransport, Http } -import pekko.stream.ActorMaterializer import pekko.stream.scaladsl.Flow import pekko.util.ByteString import com.typesafe.config.ConfigFactory @@ -43,7 +42,6 @@ class ConnectionPoolBenchmark extends CommonBenchmark { var maxConnections: String = _ implicit var system: ActorSystem = _ - implicit var mat: ActorMaterializer = _ implicit def ec: ExecutionContext = system.dispatcher private var poolSettings: ConnectionPoolSettings = _ @@ -77,7 +75,6 @@ class ConnectionPoolBenchmark extends CommonBenchmark { """) .withFallback(ConfigFactory.load()) system = ActorSystem("PekkoHttpBenchmarkSystem", config) - mat = ActorMaterializer() val responseBytes = ByteString( """HTTP/1.1 200 OK diff --git a/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/HttpEntityBenchmark.scala b/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/HttpEntityBenchmark.scala index 632048b0a..1b7d6b0a2 100644 --- a/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/HttpEntityBenchmark.scala +++ b/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/HttpEntityBenchmark.scala @@ -21,7 +21,6 @@ import pekko.dispatch.ExecutionContexts import pekko.http.CommonBenchmark import pekko.http.scaladsl.model.{ ContentTypes, HttpEntity } import pekko.stream.scaladsl.Source -import pekko.stream.{ ActorMaterializer, Materializer } import pekko.util.ByteString import com.typesafe.config.ConfigFactory import org.openjdk.jmh.annotations.{ Benchmark, Param, Setup, TearDown } @@ -31,14 +30,13 @@ class HttpEntityBenchmark extends CommonBenchmark { var entityType: String = _ implicit var system: ActorSystem = _ - implicit var mat: Materializer = _ var entity: HttpEntity = _ @Benchmark def discardBytes(): Unit = { val latch = new CountDownLatch(1) - entity.discardBytes(mat) + entity.discardBytes(system) .future .onComplete(_ => latch.countDown())(ExecutionContexts.parasitic) latch.await() @@ -54,7 +52,6 @@ class HttpEntityBenchmark extends CommonBenchmark { """) .withFallback(ConfigFactory.load()) system = ActorSystem("PekkoHttpBenchmarkSystem", config) - mat = ActorMaterializer() entity = entityType match { case "strict" => diff --git a/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/ServerProcessingBenchmark.scala b/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/ServerProcessingBenchmark.scala index 537ee7861..ceeb03aef 100644 --- a/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/ServerProcessingBenchmark.scala +++ b/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/ServerProcessingBenchmark.scala @@ -23,7 +23,6 @@ import pekko.http.scaladsl.Http import pekko.http.scaladsl.model.HttpRequest import pekko.http.scaladsl.model.HttpResponse import pekko.http.scaladsl.settings.ServerSettings -import pekko.stream.ActorMaterializer import pekko.stream.scaladsl.Flow import pekko.stream.scaladsl.Source import pekko.stream.scaladsl.TLSPlacebo @@ -37,7 +36,6 @@ class ServerProcessingBenchmark extends CommonBenchmark { var httpFlow: Flow[ByteString, ByteString, Any] = _ implicit var system: ActorSystem = _ - implicit var mat: ActorMaterializer = _ @Benchmark @OperationsPerInvocation(10000) @@ -62,7 +60,7 @@ class ServerProcessingBenchmark extends CommonBenchmark { """) .withFallback(ConfigFactory.load()) system = ActorSystem("PekkoHttpBenchmarkSystem", config) - mat = ActorMaterializer() + httpFlow = Flow[HttpRequest].map(_ => response).join( HttpServerBluePrint(ServerSettings(system), NoLogging, false, Http().dateHeaderRendering).atop( diff --git a/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/StreamServerProcessingBenchmark.scala b/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/StreamServerProcessingBenchmark.scala index 64a23b5df..1dbcacbd7 100644 --- a/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/StreamServerProcessingBenchmark.scala +++ b/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/StreamServerProcessingBenchmark.scala @@ -27,7 +27,6 @@ import pekko.http.scaladsl.model.HttpRequest import pekko.http.scaladsl.model.HttpResponse import pekko.http.scaladsl.model.headers import pekko.http.scaladsl.settings.ServerSettings -import pekko.stream.ActorMaterializer import pekko.stream.scaladsl.Flow import pekko.stream.scaladsl.Sink import pekko.stream.scaladsl.Source @@ -57,7 +56,6 @@ class StreamServerProcessingBenchmark extends CommonBenchmark { var httpFlow: Flow[ByteString, ByteString, Any] = _ implicit var system: ActorSystem = _ - implicit var mat: ActorMaterializer = _ @Benchmark def benchRequestProcessing(): Unit = { @@ -84,7 +82,6 @@ class StreamServerProcessingBenchmark extends CommonBenchmark { """) .withFallback(ConfigFactory.load()) system = ActorSystem("PekkoHttpBenchmarkSystem", config) - mat = ActorMaterializer() val bytesPerChunk = totalBytes.toInt / numChunks.toInt totalExpectedBytes = numRequestsPerConnection.toInt * bytesPerChunk * numChunks.toInt diff --git a/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/http2/H2ClientServerBenchmark.scala b/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/http2/H2ClientServerBenchmark.scala index fd1afd074..d09f72eb3 100644 --- a/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/http2/H2ClientServerBenchmark.scala +++ b/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/http2/H2ClientServerBenchmark.scala @@ -21,7 +21,6 @@ import pekko.http.impl.engine.server.ServerTerminator import pekko.http.scaladsl.Http import pekko.http.scaladsl.model.{ HttpRequest, HttpResponse } import pekko.http.scaladsl.settings.{ ClientConnectionSettings, ServerSettings } -import pekko.stream.ActorMaterializer import pekko.stream.TLSProtocol.{ SslTlsInbound, SslTlsOutbound } import pekko.stream.scaladsl.{ BidiFlow, Flow, Keep, Sink, Source } import pekko.util.ByteString @@ -38,7 +37,6 @@ import scala.concurrent.{ Await, ExecutionContext, Future } class H2ClientServerBenchmark extends CommonBenchmark with H2RequestResponseBenchmark { var httpFlow: Flow[HttpRequest, HttpResponse, Any] = _ implicit var system: ActorSystem = _ - implicit var mat: ActorMaterializer = _ val numRequests = 1000 @@ -72,7 +70,6 @@ class H2ClientServerBenchmark extends CommonBenchmark with H2RequestResponseBenc initRequestResponse() system = ActorSystem("PekkoHttpBenchmarkSystem", config) - mat = ActorMaterializer() val settings = implicitly[ServerSettings] val log = system.log implicit val ec = system.dispatcher diff --git a/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/http2/H2ServerProcessingBenchmark.scala b/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/http2/H2ServerProcessingBenchmark.scala index d24e5b7fc..b1685fbb1 100644 --- a/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/http2/H2ServerProcessingBenchmark.scala +++ b/http-bench-jmh/src/main/scala/org/apache/pekko/http/impl/engine/http2/H2ServerProcessingBenchmark.scala @@ -19,7 +19,6 @@ import pekko.http.CommonBenchmark import pekko.http.impl.engine.server.ServerTerminator import pekko.http.scaladsl.Http import pekko.http.scaladsl.settings.ServerSettings -import pekko.stream.ActorMaterializer import pekko.stream.TLSProtocol.{ SslTlsInbound, SslTlsOutbound } import pekko.stream.scaladsl.{ Flow, Keep, Sink, Source } import pekko.util.ByteString @@ -33,7 +32,6 @@ class H2ServerProcessingBenchmark extends CommonBenchmark with H2RequestResponse var httpFlow: Flow[ByteString, ByteString, Any] = _ implicit var system: ActorSystem = _ - implicit var mat: ActorMaterializer = _ val packedResponse = ByteString(1, 5, 0, 0) // a HEADERS frame with end_stream == true @@ -71,7 +69,6 @@ class H2ServerProcessingBenchmark extends CommonBenchmark with H2RequestResponse initRequestResponse() system = ActorSystem("PekkoHttpBenchmarkSystem", config) - mat = ActorMaterializer() val settings = implicitly[ServerSettings] val log = system.log implicit val ec = system.dispatcher diff --git a/http-bench-jmh/src/main/scala/org/apache/pekko/http/scaladsl/unmarshalling/sse/LineParserBenchmark.scala b/http-bench-jmh/src/main/scala/org/apache/pekko/http/scaladsl/unmarshalling/sse/LineParserBenchmark.scala index f10323f71..eaa73a982 100644 --- a/http-bench-jmh/src/main/scala/org/apache/pekko/http/scaladsl/unmarshalling/sse/LineParserBenchmark.scala +++ b/http-bench-jmh/src/main/scala/org/apache/pekko/http/scaladsl/unmarshalling/sse/LineParserBenchmark.scala @@ -19,7 +19,6 @@ import java.util.concurrent.TimeUnit import org.apache.pekko import pekko.Done import pekko.actor.ActorSystem -import pekko.stream.ActorMaterializer import pekko.stream.scaladsl.{ FileIO, Keep, RunnableGraph, Sink, Source } import pekko.util.ByteString import org.openjdk.jmh.annotations._ @@ -33,7 +32,6 @@ import scala.concurrent.duration._ @BenchmarkMode(Array(Mode.AverageTime)) class LineParserBenchmark { implicit val system: ActorSystem = ActorSystem("line-parser-benchmark") - implicit val mat: ActorMaterializer = ActorMaterializer() // @formatter:off @Param(Array( diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/PoolInterface.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/PoolInterface.scala index 9e8d144e0..e4f97751f 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/PoolInterface.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/PoolInterface.scala @@ -24,7 +24,6 @@ import pekko.http.impl.util._ import pekko.http.scaladsl.model._ import pekko.http.scaladsl.Http import pekko.macros.LogHelper -import pekko.stream.ActorMaterializer import pekko.stream.Attributes import pekko.stream.FlowShape import pekko.stream.Inlet @@ -69,7 +68,7 @@ private[http] object PoolInterface { import poolId.hcps import hcps._ import setup.{ connectionContext, settings } - implicit val system = fm.asInstanceOf[ActorMaterializer].system + implicit val system = fm.system val log: LoggingAdapter = Logging(system, poolId)(PoolLogSource) log.debug("Creating pool.") diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpEntity.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpEntity.scala index a770d1def..8d9559836 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpEntity.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpEntity.scala @@ -85,7 +85,7 @@ sealed trait HttpEntity extends jm.HttpEntity { */ def toStrict(timeout: FiniteDuration)(implicit fm: Materializer): Future[HttpEntity.Strict] = { import pekko.http.impl.util._ - val config = fm.asInstanceOf[ActorMaterializer].system.settings.config + val config = fm.system.settings.config toStrict(timeout, config.getPossiblyInfiniteBytes("pekko.http.parsing.max-to-strict-bytes")) } diff --git a/http-core/src/test/java/org/apache/pekko/http/JavaTestServer.java b/http-core/src/test/java/org/apache/pekko/http/JavaTestServer.java index 0b007abfa..7f6141720 100644 --- a/http-core/src/test/java/org/apache/pekko/http/JavaTestServer.java +++ b/http-core/src/test/java/org/apache/pekko/http/JavaTestServer.java @@ -15,7 +15,6 @@ import org.apache.pekko.NotUsed; import org.apache.pekko.actor.ActorSystem; -import org.apache.pekko.http.javadsl.ConnectHttp; import org.apache.pekko.http.javadsl.Http; import org.apache.pekko.http.javadsl.ServerBinding; import org.apache.pekko.http.javadsl.model.JavaApiTestCases; @@ -23,8 +22,6 @@ import org.apache.pekko.http.javadsl.model.ws.TextMessage; import org.apache.pekko.http.javadsl.model.ws.WebSocket; import org.apache.pekko.japi.JavaPartialFunction; -import org.apache.pekko.stream.ActorMaterializer; -import org.apache.pekko.stream.Materializer; import org.apache.pekko.stream.javadsl.Flow; import org.apache.pekko.stream.javadsl.Source; diff --git a/http-core/src/test/java/org/apache/pekko/http/javadsl/GracefulTerminationCompileTest.java b/http-core/src/test/java/org/apache/pekko/http/javadsl/GracefulTerminationCompileTest.java index e408a864f..94787e21a 100644 --- a/http-core/src/test/java/org/apache/pekko/http/javadsl/GracefulTerminationCompileTest.java +++ b/http-core/src/test/java/org/apache/pekko/http/javadsl/GracefulTerminationCompileTest.java @@ -17,8 +17,6 @@ import org.apache.pekko.http.javadsl.model.HttpRequest; import org.apache.pekko.http.javadsl.model.HttpResponse; import org.apache.pekko.japi.function.Function; -import org.apache.pekko.stream.ActorMaterializer; -import org.apache.pekko.stream.Materializer; import java.time.Duration; import java.util.concurrent.CompletableFuture; diff --git a/http-core/src/test/java/org/apache/pekko/http/javadsl/WSEchoTestClientApp.java b/http-core/src/test/java/org/apache/pekko/http/javadsl/WSEchoTestClientApp.java index 9d6d75de6..9e6efbbbe 100644 --- a/http-core/src/test/java/org/apache/pekko/http/javadsl/WSEchoTestClientApp.java +++ b/http-core/src/test/java/org/apache/pekko/http/javadsl/WSEchoTestClientApp.java @@ -20,7 +20,6 @@ import org.apache.pekko.http.javadsl.model.ws.TextMessage; import org.apache.pekko.http.javadsl.model.ws.WebSocketRequest; import org.apache.pekko.japi.function.Function; -import org.apache.pekko.stream.ActorMaterializer; import org.apache.pekko.stream.Materializer; import org.apache.pekko.stream.javadsl.Flow; import org.apache.pekko.stream.javadsl.Keep; @@ -51,7 +50,7 @@ public static void main(String[] args) throws Exception { ActorSystem system = ActorSystem.create(); try { - final Materializer materializer = ActorMaterializer.create(system); + final Materializer materializer = Materializer.createMaterializer(system); final Future ignoredMessage = Futures.successful((Message) TextMessage.create("blub")); diff --git a/http-core/src/test/scala/io/pekko/integrationtest/http/HttpModelIntegrationSpec.scala b/http-core/src/test/scala/io/pekko/integrationtest/http/HttpModelIntegrationSpec.scala index 82a9da35b..9cf55f763 100644 --- a/http-core/src/test/scala/io/pekko/integrationtest/http/HttpModelIntegrationSpec.scala +++ b/http-core/src/test/scala/io/pekko/integrationtest/http/HttpModelIntegrationSpec.scala @@ -23,7 +23,6 @@ import pekko.util.ByteString import pekko.actor.ActorSystem import pekko.http.ccompat._ // required for Scala 2.12 compilation import pekko.http.scaladsl.model._ -import pekko.stream.ActorMaterializer import pekko.stream.scaladsl._ import pekko.testkit._ import headers._ @@ -56,8 +55,6 @@ class HttpModelIntegrationSpec extends AnyWordSpec with Matchers with BeforeAndA override def afterAll() = TestKit.shutdownActorSystem(system) - implicit val materializer: ActorMaterializer = ActorMaterializer() - "External HTTP libraries" should { "be able to get String headers and an Array[Byte] body out of an HttpRequest" in { diff --git a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/PrepareResponseSpec.scala b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/PrepareResponseSpec.scala index 3e258b92c..614298a8e 100644 --- a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/PrepareResponseSpec.scala +++ b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/PrepareResponseSpec.scala @@ -24,7 +24,7 @@ import pekko.http.impl.engine.parsing.ParserOutput.{ } import pekko.http.scaladsl.model._ import pekko.http.scaladsl.settings.ParserSettings -import pekko.stream.{ ActorMaterializer, Attributes } +import pekko.stream.Attributes import pekko.stream.scaladsl.{ Sink, Source } import pekko.stream.testkit.{ TestPublisher, TestSubscriber } import pekko.util.ByteString @@ -63,8 +63,6 @@ class PrepareResponseSpec extends PekkoSpec { "The PrepareRequest stage" should { "not lose demand that comes in while streaming entity" in { - implicit val mat: ActorMaterializer = ActorMaterializer() - val inProbe = TestPublisher.manualProbe[ParserOutput.ResponseOutput]() val responseProbe = TestSubscriber.manualProbe[HttpResponse]() @@ -108,8 +106,6 @@ class PrepareResponseSpec extends PekkoSpec { } "not lose demand that comes in while handling strict entity" in { - implicit val mat: ActorMaterializer = ActorMaterializer() - val inProbe = TestPublisher.manualProbe[ParserOutput.ResponseOutput]() val responseProbe = TestSubscriber.manualProbe[HttpResponse]() @@ -144,8 +140,6 @@ class PrepareResponseSpec extends PekkoSpec { "complete entity stream then complete stage when downstream cancels" in { // to make it possible to cancel a big file download for example // without downloading the entire response first - implicit val mat: ActorMaterializer = ActorMaterializer() - val inProbe = TestPublisher.manualProbe[ParserOutput.ResponseOutput]() val responseProbe = TestSubscriber.manualProbe[HttpResponse]() @@ -185,8 +179,6 @@ class PrepareResponseSpec extends PekkoSpec { } "complete stage when downstream cancels before end of strict request has arrived" in { - implicit val mat: ActorMaterializer = ActorMaterializer() - val inProbe = TestPublisher.manualProbe[ParserOutput.ResponseOutput]() val responseProbe = TestSubscriber.manualProbe[HttpResponse]() @@ -213,8 +205,6 @@ class PrepareResponseSpec extends PekkoSpec { } "cancel entire stage when the entity stream is canceled" in { - implicit val mat: ActorMaterializer = ActorMaterializer() - val inProbe = TestPublisher.manualProbe[ParserOutput.ResponseOutput]() val responseProbe = TestSubscriber.manualProbe[HttpResponse]() diff --git a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/ResponseParsingMergeSpec.scala b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/ResponseParsingMergeSpec.scala index 65ae7dc0b..9cc6126b5 100644 --- a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/ResponseParsingMergeSpec.scala +++ b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/ResponseParsingMergeSpec.scala @@ -23,7 +23,7 @@ import pekko.http.scaladsl.settings.ParserSettings import pekko.stream.TLSProtocol.SessionBytes import pekko.stream.scaladsl.{ GraphDSL, RunnableGraph, Sink, Source } import pekko.stream.testkit.{ TestPublisher, TestSubscriber } -import pekko.stream.{ ActorMaterializer, Attributes, ClosedShape } +import pekko.stream.{ Attributes, ClosedShape } import pekko.testkit.PekkoSpec import pekko.util.ByteString @@ -34,8 +34,6 @@ class ResponseParsingMergeSpec extends PekkoSpec { "The ResponseParsingMerge stage" should { "not lose entity truncation errors on upstream finish" in { - implicit val mat: ActorMaterializer = ActorMaterializer() - val inBypassProbe = TestPublisher.manualProbe[OutgoingConnectionBlueprint.BypassData]() val inSessionBytesProbe = TestPublisher.manualProbe[SessionBytes]() val responseProbe = TestSubscriber.manualProbe[List[ParserOutput.ResponseOutput]]() diff --git a/http-marshallers-java/http-jackson/src/test/java/org/apache/pekko/http/javadsl/marshallers/jackson/JacksonTest.java b/http-marshallers-java/http-jackson/src/test/java/org/apache/pekko/http/javadsl/marshallers/jackson/JacksonTest.java index d1b74c074..17532fdaf 100644 --- a/http-marshallers-java/http-jackson/src/test/java/org/apache/pekko/http/javadsl/marshallers/jackson/JacksonTest.java +++ b/http-marshallers-java/http-jackson/src/test/java/org/apache/pekko/http/javadsl/marshallers/jackson/JacksonTest.java @@ -21,24 +21,17 @@ import org.apache.pekko.actor.ActorSystem; import org.apache.pekko.http.javadsl.model.ContentTypes; import org.apache.pekko.http.javadsl.model.HttpEntities; -import org.apache.pekko.http.javadsl.model.HttpEntity; import org.apache.pekko.http.javadsl.model.HttpRequest; import org.apache.pekko.http.javadsl.model.RequestEntity; -import org.apache.pekko.http.javadsl.server.ExceptionHandler; import org.apache.pekko.http.javadsl.server.Route; -import org.apache.pekko.http.javadsl.settings.RoutingSettings; import org.apache.pekko.http.javadsl.testkit.JUnitRouteTest; -import org.apache.pekko.stream.ActorMaterializer; -import org.apache.pekko.stream.Materializer; import org.junit.Test; -import org.scalatestplus.junit.JUnitSuite; import java.util.concurrent.CompletionStage; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; public class JacksonTest extends JUnitRouteTest { @@ -65,7 +58,6 @@ public Config additionalConfig() { public void failingToUnmarshallShouldProvideFailureDetails() throws Exception { ActorSystem sys = ActorSystem.create("test"); try { - Materializer materializer = ActorMaterializer.create(sys); CompletionStage unmarshalled = Jackson.unmarshaller(SomeData.class).unmarshal(invalidEntity, system()); diff --git a/http-marshallers-scala/http-spray-json/src/test/scala/org/apache/pekko/http/scaladsl/marshallers/sprayjson/SprayJsonSupportSpec.scala b/http-marshallers-scala/http-spray-json/src/test/scala/org/apache/pekko/http/scaladsl/marshallers/sprayjson/SprayJsonSupportSpec.scala index 3bd99ea2d..48a440655 100644 --- a/http-marshallers-scala/http-spray-json/src/test/scala/org/apache/pekko/http/scaladsl/marshallers/sprayjson/SprayJsonSupportSpec.scala +++ b/http-marshallers-scala/http-spray-json/src/test/scala/org/apache/pekko/http/scaladsl/marshallers/sprayjson/SprayJsonSupportSpec.scala @@ -20,7 +20,6 @@ import pekko.actor.ActorSystem import pekko.http.scaladsl.marshalling.Marshal import pekko.http.scaladsl.model.MessageEntity import pekko.http.scaladsl.unmarshalling.Unmarshal -import pekko.stream.ActorMaterializer import pekko.util.ByteString import org.scalatest.concurrent.ScalaFutures import spray.json.{ JsArray, JsString, JsValue } @@ -35,7 +34,6 @@ class SprayJsonSupportSpec extends AnyWordSpec with Matchers with ScalaFutures { implicit val exampleFormat: RootJsonFormat[Example] = jsonFormat1(Example.apply) implicit val sys: ActorSystem = ActorSystem("SprayJsonSupportSpec") - implicit val mat: ActorMaterializer = ActorMaterializer() implicit val ec: ExecutionContext = sys.dispatcher val TestString = diff --git a/http-tests/src/main/java/org/apache/pekko/http/javadsl/server/examples/petstore/PetStoreExample.java b/http-tests/src/main/java/org/apache/pekko/http/javadsl/server/examples/petstore/PetStoreExample.java index 462fbea03..2f514121c 100644 --- a/http-tests/src/main/java/org/apache/pekko/http/javadsl/server/examples/petstore/PetStoreExample.java +++ b/http-tests/src/main/java/org/apache/pekko/http/javadsl/server/examples/petstore/PetStoreExample.java @@ -14,14 +14,12 @@ package org.apache.pekko.http.javadsl.server.examples.petstore; import org.apache.pekko.actor.ActorSystem; -import org.apache.pekko.http.javadsl.ConnectHttp; import org.apache.pekko.http.javadsl.Http; // #imports import org.apache.pekko.http.javadsl.marshallers.jackson.Jackson; import org.apache.pekko.http.javadsl.model.StatusCodes; // #imports import org.apache.pekko.http.javadsl.server.Route; -import org.apache.pekko.stream.ActorMaterializer; import java.io.IOException; // #imports diff --git a/http-tests/src/test/java/org/apache/pekko/http/javadsl/unmarshalling/sse/EventStreamUnmarshallingTest.java b/http-tests/src/test/java/org/apache/pekko/http/javadsl/unmarshalling/sse/EventStreamUnmarshallingTest.java index 42e9e5d24..eb91d3970 100644 --- a/http-tests/src/test/java/org/apache/pekko/http/javadsl/unmarshalling/sse/EventStreamUnmarshallingTest.java +++ b/http-tests/src/test/java/org/apache/pekko/http/javadsl/unmarshalling/sse/EventStreamUnmarshallingTest.java @@ -18,8 +18,6 @@ import org.apache.pekko.actor.ActorSystem; import org.apache.pekko.http.javadsl.model.HttpEntity; -import org.apache.pekko.stream.ActorMaterializer; -import org.apache.pekko.stream.Materializer; import org.apache.pekko.stream.javadsl.Sink; import org.apache.pekko.http.javadsl.model.sse.ServerSentEvent; import org.apache.pekko.http.scaladsl.unmarshalling.sse.EventStreamUnmarshallingSpec; @@ -36,8 +34,6 @@ public class EventStreamUnmarshallingTest extends JUnitSuite { public void testFromEventsStream() throws Exception { ActorSystem system = ActorSystem.create(); try { - Materializer mat = ActorMaterializer.create(system); - List events = EventStreamUnmarshallingSpec.eventsAsJava(); HttpEntity entity = EventStreamUnmarshallingSpec.entity(); @@ -45,7 +41,7 @@ public void testFromEventsStream() throws Exception { List unmarshalledEvents = EventStreamUnmarshalling.fromEventsStream(system) .unmarshal(entity, system) - .thenCompose(source -> source.runWith(Sink.seq(), mat)) + .thenCompose(source -> source.runWith(Sink.seq(), system)) .toCompletableFuture() .get(3000, TimeUnit.SECONDS); // #event-stream-unmarshalling-example diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/CustomMediaTypesSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/CustomMediaTypesSpec.scala index 60ccb9c6a..2c7a898bc 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/CustomMediaTypesSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/CustomMediaTypesSpec.scala @@ -18,7 +18,6 @@ import pekko.http.scaladsl.client.RequestBuilding import pekko.http.scaladsl.model.MediaType.WithFixedCharset import pekko.http.scaladsl.model._ import pekko.http.scaladsl.server.Directives -import pekko.stream.ActorMaterializer import pekko.testkit._ import pekko.util.ByteString import org.scalatest.concurrent.ScalaFutures @@ -27,8 +26,6 @@ import scala.concurrent.duration._ class CustomMediaTypesSpec extends PekkoSpec with ScalaFutures with Directives with RequestBuilding { - implicit val mat: ActorMaterializer = ActorMaterializer() - "Http" should { "find media types in a set if they differ in casing" in { val set: java.util.Set[MediaType] = new java.util.HashSet diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/FormDataSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/FormDataSpec.scala index 9304a8190..340eb487e 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/FormDataSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/FormDataSpec.scala @@ -14,14 +14,12 @@ package org.apache.pekko.http.scaladsl import org.apache.pekko -import pekko.stream.ActorMaterializer import pekko.http.scaladsl.unmarshalling.Unmarshal import pekko.http.scaladsl.marshalling.Marshal import pekko.http.scaladsl.model._ import pekko.testkit.PekkoSpec class FormDataSpec extends PekkoSpec { - implicit val materializer: ActorMaterializer = ActorMaterializer() import system.dispatcher val formData = FormData(Map("surname" -> "Smith", "age" -> "42")) diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/TestSingleRequest.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/TestSingleRequest.scala index 59b28bfca..1b43751fe 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/TestSingleRequest.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/TestSingleRequest.scala @@ -18,7 +18,6 @@ import pekko.http.scaladsl.model.HttpRequest import pekko.util.ByteString import com.typesafe.config.{ Config, ConfigFactory } import pekko.actor.ActorSystem -import pekko.stream._ import scala.concurrent.Await import scala.concurrent.duration._ import scala.io.StdIn @@ -30,7 +29,6 @@ object TestSingleRequest extends App { pekko.stream.materializer.debug.fuzzing-mode = off """) implicit val system: ActorSystem = ActorSystem("ServerTest", testConf) - implicit val materializer: ActorMaterializer = ActorMaterializer() import system.dispatcher val url = StdIn.readLine("url? ") diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/CodecSpecSupport.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/CodecSpecSupport.scala index 896bbc421..efdf540d8 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/CodecSpecSupport.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/CodecSpecSupport.scala @@ -16,7 +16,6 @@ package org.apache.pekko.http.scaladsl.coding import org.scalatest.{ BeforeAndAfterAll, Suite } import org.apache.pekko import pekko.actor.ActorSystem -import pekko.stream.ActorMaterializer import pekko.testkit.TestKit import pekko.util.ByteString import org.scalatest.matchers.should.Matchers @@ -83,7 +82,6 @@ est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscin "\r\n", "\n") implicit val system: ActorSystem = ActorSystem(getClass.getSimpleName) - implicit val materializer: ActorMaterializer = ActorMaterializer() override def afterAll() = TestKit.shutdownActorSystem(system) } diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/marshalling/MarshallingSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/marshalling/MarshallingSpec.scala index 228488d4b..fe0cb7446 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/marshalling/MarshallingSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/marshalling/MarshallingSpec.scala @@ -22,7 +22,6 @@ import pekko.http.scaladsl.model.MediaTypes._ import pekko.http.scaladsl.model._ import pekko.http.scaladsl.model.headers._ import pekko.http.scaladsl.testkit.MarshallingTestUtils -import pekko.stream.ActorMaterializer import pekko.stream.scaladsl.Source import pekko.testkit.TestKit import pekko.util.ByteString @@ -37,7 +36,6 @@ import org.scalatest.matchers.should.Matchers class MarshallingSpec extends AnyFreeSpec with Matchers with BeforeAndAfterAll with MultipartMarshallers with MarshallingTestUtils { implicit val system: ActorSystem = ActorSystem(getClass.getSimpleName) - implicit val materializer: ActorMaterializer = ActorMaterializer() import system.dispatcher override val testConfig = ConfigFactory.load() diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/ConnectionTestApp.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/ConnectionTestApp.scala index 70f42abd9..8f00aa4c5 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/ConnectionTestApp.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/ConnectionTestApp.scala @@ -18,7 +18,7 @@ import pekko.actor._ import pekko.http.scaladsl.Http import pekko.http.scaladsl.model.{ HttpRequest, HttpResponse, Uri } import pekko.stream.scaladsl.{ Flow, Sink, Source } -import pekko.stream.{ ActorMaterializer, OverflowStrategy } +import pekko.stream.OverflowStrategy import com.typesafe.config.{ Config, ConfigFactory } import scala.concurrent.Future @@ -39,7 +39,6 @@ object ConnectionTestApp { implicit val system: ActorSystem = ActorSystem("ConnectionTest", testConf) import system.dispatcher - implicit val materializer: ActorMaterializer = ActorMaterializer() val clientFlow = Http().superPool[Int]() diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/DontLeakActorsOnFailingConnectionSpecs.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/DontLeakActorsOnFailingConnectionSpecs.scala index 3f9f33fd8..c34a3ffd0 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/DontLeakActorsOnFailingConnectionSpecs.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/DontLeakActorsOnFailingConnectionSpecs.scala @@ -14,18 +14,17 @@ package org.apache.pekko.http.scaladsl.server import java.util.concurrent.{ CountDownLatch, TimeUnit } - import org.apache.pekko import pekko.actor.ActorSystem import pekko.event.{ LogSource, Logging } import pekko.http.impl.util.WithLogCapturing import pekko.http.scaladsl.Http import pekko.http.scaladsl.model.{ HttpRequest, HttpResponse, Uri } -import pekko.stream.ActorMaterializer import pekko.stream.scaladsl.{ Sink, Source } import pekko.stream.testkit.Utils.assertAllStagesStopped import pekko.testkit.TestKit import com.typesafe.config.ConfigFactory +import org.apache.pekko.stream.Materializer import org.scalatest.BeforeAndAfterAll import scala.concurrent.Await @@ -48,7 +47,7 @@ abstract class DontLeakActorsOnFailingConnectionSpecs(poolImplementation: String http.host-connection-pool.base-connection-backoff = 0 ms }""").withFallback(ConfigFactory.load()) implicit val system: ActorSystem = ActorSystem("DontLeakActorsOnFailingConnectionSpecs-" + poolImplementation, config) - implicit val materializer: ActorMaterializer = ActorMaterializer() + implicit val materializer: Materializer = Materializer.createMaterializer(system) val log = Logging(system, getClass)(LogSource.fromClass) diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/SizeLimitSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/SizeLimitSpec.scala index 8e90215ab..bc19f6c3c 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/SizeLimitSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/SizeLimitSpec.scala @@ -23,7 +23,6 @@ import pekko.http.scaladsl.model.HttpEntity.Chunk import pekko.http.scaladsl.model._ import pekko.http.scaladsl.model.headers.{ `Content-Encoding`, HttpEncoding, HttpEncodings } import pekko.http.scaladsl.server.Directives._ -import pekko.stream.ActorMaterializer import pekko.stream.scaladsl.{ Flow, Source } import pekko.testkit.TestKit import pekko.util.ByteString @@ -55,7 +54,6 @@ class SizeLimitSpec extends AnyWordSpec with Matchers with RequestBuilding with """) implicit val system: ActorSystem = ActorSystem(getClass.getSimpleName, testConf) import system.dispatcher - implicit val materializer: ActorMaterializer = ActorMaterializer() val random = new scala.util.Random(42) implicit val defaultPatience: PatienceConfig = PatienceConfig(timeout = Span(2, Seconds), interval = Span(5, Millis)) diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/TcpLeakApp.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/TcpLeakApp.scala index 19188b62d..0f5f767b3 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/TcpLeakApp.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/TcpLeakApp.scala @@ -19,7 +19,7 @@ import org.apache.pekko import pekko.actor.{ ActorSystem, ActorSystemImpl } import pekko.event.Logging import pekko.stream.scaladsl._ -import pekko.stream.{ ActorAttributes, ActorMaterializer } +import pekko.stream.ActorAttributes import pekko.util.ByteString import com.typesafe.config.{ Config, ConfigFactory } import scala.io.StdIn @@ -31,7 +31,6 @@ object TcpLeakApp extends App { pekko.log-dead-letters = on pekko.io.tcp.trace-logging = on""") implicit val system: ActorSystem = ActorSystem("ServerTest", testConf) - implicit val fm: ActorMaterializer = ActorMaterializer() import system.dispatcher diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/TestServer.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/TestServer.scala index f0db22d4a..399194345 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/TestServer.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/TestServer.scala @@ -21,7 +21,6 @@ import pekko.http.scaladsl.model.{ HttpResponse, StatusCodes } import pekko.http.scaladsl.server.directives.Credentials import com.typesafe.config.{ Config, ConfigFactory } import pekko.actor.ActorSystem -import pekko.stream._ import pekko.stream.scaladsl._ import pekko.http.scaladsl.Http import pekko.http.scaladsl.common.EntityStreamingSupport @@ -40,7 +39,6 @@ object TestServer extends App { implicit val system: ActorSystem = ActorSystem("ServerTest", testConf) implicit val ec: ExecutionContext = system.dispatcher - implicit val materializer: ActorMaterializer = ActorMaterializer() import spray.json.DefaultJsonProtocol._ import pekko.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._ diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/unmarshalling/UnmarshallingSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/unmarshalling/UnmarshallingSpec.scala index 874286473..7da31ab22 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/unmarshalling/UnmarshallingSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/unmarshalling/UnmarshallingSpec.scala @@ -21,7 +21,6 @@ import org.scalatest.BeforeAndAfterAll import pekko.http.scaladsl.testkit.ScalatestUtils import pekko.actor.ActorSystem import pekko.http.scaladsl.model.MediaType.WithFixedCharset -import pekko.stream.ActorMaterializer import pekko.http.scaladsl.model._ import pekko.testkit._ import com.typesafe.config.ConfigFactory @@ -34,7 +33,6 @@ import org.scalatest.matchers.should.Matchers class UnmarshallingSpec extends AnyFreeSpec with Matchers with BeforeAndAfterAll with ScalatestUtils { implicit val system: ActorSystem = ActorSystem(getClass.getSimpleName) - implicit val materializer: ActorMaterializer = ActorMaterializer() override val testConfig = ConfigFactory.load() diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/unmarshalling/sse/BaseUnmarshallingSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/unmarshalling/sse/BaseUnmarshallingSpec.scala index 713450e68..17421c715 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/unmarshalling/sse/BaseUnmarshallingSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/unmarshalling/sse/BaseUnmarshallingSpec.scala @@ -18,7 +18,6 @@ package sse import org.apache.pekko import pekko.actor.ActorSystem -import pekko.stream.{ ActorMaterializer, Materializer } import org.scalatest.{ BeforeAndAfterAll, Suite } import scala.concurrent.Await import scala.concurrent.duration.DurationInt @@ -28,9 +27,6 @@ trait BaseUnmarshallingSpec extends BeforeAndAfterAll { this: Suite => protected implicit val system: ActorSystem = ActorSystem() - protected implicit val mat: Materializer = - ActorMaterializer() - override protected def afterAll() = { Await.ready(system.terminate(), 42.seconds) super.afterAll() diff --git a/http/src/main/java/org/apache/pekko/http/javadsl/server/HttpApp.java b/http/src/main/java/org/apache/pekko/http/javadsl/server/HttpApp.java index 0f1af3271..0b7b09946 100644 --- a/http/src/main/java/org/apache/pekko/http/javadsl/server/HttpApp.java +++ b/http/src/main/java/org/apache/pekko/http/javadsl/server/HttpApp.java @@ -19,7 +19,6 @@ import org.apache.pekko.http.javadsl.Http; import org.apache.pekko.http.javadsl.ServerBinding; import org.apache.pekko.http.javadsl.settings.ServerSettings; -import org.apache.pekko.stream.ActorMaterializer; import com.typesafe.config.ConfigFactory; import java.io.IOException; @@ -102,7 +101,6 @@ public void startServer( final ActorSystem theSystem = system.orElseGet(() -> ActorSystem.create(Logging.simpleName(this).replaceAll("\\$", ""))); systemReference.set(theSystem); - final ActorMaterializer materializer = ActorMaterializer.create(theSystem); CompletionStage bindingFuture = Http.get(theSystem).newServerAt(host, port).withSettings(settings).bind(routes()); 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 8b4cf2db5..e1eeacba8 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 @@ -19,7 +19,6 @@ import org.apache.pekko import pekko.http.impl.util.{ ExampleHttpContexts, WithLogCapturing } import pekko.http.scaladsl.Http import pekko.http.scaladsl.server.Directives -import pekko.stream.{ ActorMaterializer, Materializer } import pekko.testkit._ import pekko.util.ByteString import org.scalatest.concurrent.ScalaFutures @@ -45,7 +44,6 @@ class H2SpecIntegrationSpec extends PekkoFreeSpec( """) with Directives with ScalaFutures with WithLogCapturing { implicit val ec: ExecutionContext = system.dispatcher - implicit val mat: Materializer = ActorMaterializer() override def expectedTestDuration = 5.minutes // because slow jenkins, generally finishes below 1 or 2 minutes diff --git a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/ProtocolSwitchSpec.scala b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/ProtocolSwitchSpec.scala index e8515064b..fd6e714cd 100644 --- a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/ProtocolSwitchSpec.scala +++ b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/ProtocolSwitchSpec.scala @@ -18,8 +18,6 @@ import org.apache.pekko import pekko.Done import pekko.http.impl.engine.server.ServerTerminator import pekko.http.scaladsl.Http -import pekko.stream.ActorMaterializer -import pekko.stream.Materializer import pekko.stream.OverflowStrategy import pekko.stream.QueueOfferResult.Enqueued import pekko.stream.TLSProtocol._ @@ -36,8 +34,6 @@ import org.scalatest.time.{ Milliseconds, Seconds, Span } import scala.concurrent.duration.FiniteDuration class ProtocolSwitchSpec extends PekkoSpec { - implicit val mat: Materializer = ActorMaterializer() - override implicit val patience: PatienceConfig = PatienceConfig(timeout = Span(2, Seconds), interval = Span(50, Milliseconds))