From d03fb9b81030cc33e35fd497c156c81186c10bce Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sun, 29 Oct 2023 23:56:20 +0000 Subject: [PATCH] more changes --- .../javadsl/WebSocketClientExampleTest.java | 15 ++++++------- .../server/HttpServerExampleDocTest.java | 22 +++++++------------ .../server/PekkoHttp1020MigrationExample.java | 3 +-- .../BasicDirectivesExamplesTest.java | 9 -------- .../http/javadsl/WSEchoTestClientApp.java | 3 +-- .../client/ResponseParsingMergeSpec.scala | 4 +--- .../scaladsl/server/ConnectionTestApp.scala | 3 +-- ...ntLeakActorsOnFailingConnectionSpecs.scala | 5 ++--- .../http/scaladsl/server/SizeLimitSpec.scala | 2 -- 9 files changed, 21 insertions(+), 45 deletions(-) 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/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/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/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-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 8668df8d1..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,7 +14,6 @@ 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 } @@ -25,7 +24,7 @@ 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.ActorMaterializer +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))