Skip to content

Commit

Permalink
more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning committed Oct 29, 2023
1 parent ce86add commit d03fb9b
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<Message, Message, NotUsed> flow =
Flow.fromSinkAndSource(
Expand Down Expand Up @@ -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<Message, Message, NotUsed> flow =
Flow.fromSinkAndSource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<IncomingConnection, CompletionStage<ServerBinding>> serverSource =
Http.get(system).bind(ConnectHttp.toHost("localhost", 8080));
Expand All @@ -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<IncomingConnection, CompletionStage<ServerBinding>> serverSource =
Http.get(system).bind(ConnectHttp.toHost("localhost", 80));
Expand Down Expand Up @@ -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<IncomingConnection, CompletionStage<ServerBinding>> serverSource =
Http.get(system).bind(ConnectHttp.toHost("localhost", 8080));
Expand Down Expand Up @@ -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<IncomingConnection, CompletionStage<ServerBinding>> serverSource =
Http.get(system).bind(ConnectHttp.toHost("localhost", 8080));
Expand Down Expand Up @@ -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<IncomingConnection, CompletionStage<ServerBinding>> serverSource =
Http.get(system).bind(ConnectHttp.toHost("localhost", 8080));
Expand Down Expand Up @@ -265,7 +262,6 @@ class Bid {

final ActorSystem system = ActorSystem.create();
final ExecutionContextExecutor dispatcher = system.dispatcher();
final ActorMaterializer materializer = ActorMaterializer.create(system);

final Unmarshaller<HttpEntity, Bid> asBid = Jackson.unmarshaller(Bid.class);

Expand All @@ -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(
Expand All @@ -302,7 +297,7 @@ void consumeEntityUsingRawDataBytes() {
final CompletionStage<IOResult> res =
bytes.runWith(
FileIO.toPath(new File("/tmp/example.out").toPath()),
materializer);
system);

return onComplete(
() -> res,
Expand Down Expand Up @@ -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(
Expand All @@ -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:
Expand All @@ -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<ServerBinding> binding =
Http.get(system)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Message> ignoredMessage =
Futures.successful((Message) TextMessage.create("blub"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

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

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

0 comments on commit d03fb9b

Please sign in to comment.