This is an automated email from the ASF dual-hosted git repository.
fanningpj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-http.git
The following commit(s) were added to refs/heads/main by this push:
new 9dd78d82b avoid Scala classes in Java example (#741)
9dd78d82b is described below
commit 9dd78d82b69a0768a547fc2c84cf80ff6d61850b
Author: PJ Fanning <[email protected]>
AuthorDate: Wed Sep 3 19:50:24 2025 +0100
avoid Scala classes in Java example (#741)
* avoid Scala classes in Java example
* javafmt
---
.../apache/pekko/http/javadsl/WSEchoTestClientApp.java | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
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 b8faa49c9..bc68e988a 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
@@ -15,7 +15,6 @@ package org.apache.pekko.http.javadsl;
import org.apache.pekko.NotUsed;
import org.apache.pekko.actor.ActorSystem;
-import org.apache.pekko.dispatch.Futures;
import org.apache.pekko.http.javadsl.model.ws.Message;
import org.apache.pekko.http.javadsl.model.ws.TextMessage;
import org.apache.pekko.http.javadsl.model.ws.WebSocketRequest;
@@ -25,11 +24,11 @@ import org.apache.pekko.stream.javadsl.Flow;
import org.apache.pekko.stream.javadsl.Keep;
import org.apache.pekko.stream.javadsl.Sink;
import org.apache.pekko.stream.javadsl.Source;
-import scala.concurrent.Future;
-import scala.concurrent.duration.FiniteDuration;
+import java.time.Duration;
import java.util.Arrays;
import java.util.List;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeUnit;
@@ -52,14 +51,11 @@ public class WSEchoTestClientApp {
try {
final Materializer materializer =
Materializer.createMaterializer(system);
- final Future<Message> ignoredMessage =
- Futures.successful((Message) TextMessage.create("blub"));
- final Future<Message> delayedCompletion =
+ final CompletableFuture<Message> ignoredMessage =
+ CompletableFuture.completedFuture((Message)
TextMessage.create("blub"));
+ final CompletionStage<Message> delayedCompletion =
org.apache.pekko.pattern.Patterns.after(
- FiniteDuration.apply(1, "second"),
- system.scheduler(),
- system.dispatcher(),
- ignoredMessage);
+ Duration.ofSeconds(1), system.scheduler(), system.dispatcher(),
() -> ignoredMessage);
Source<Message, NotUsed> echoSource =
Source.from(
@@ -67,7 +63,7 @@ public class WSEchoTestClientApp {
TextMessage.create("abc"),
TextMessage.create("def"),
TextMessage.create("ghi")))
- .concat(Source.future(delayedCompletion).drop(1));
+ .concat(Source.completionStage(delayedCompletion).drop(1));
Sink<Message, CompletionStage<List<String>>> echoSink =
Flow.of(Message.class)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]