fix: Actually set halfClosed in half closed sample (#30404)
This commit is contained in:
parent
d2345ef920
commit
79cff55685
2 changed files with 12 additions and 2 deletions
|
|
@ -14,6 +14,8 @@ import akka.stream.testkit.TestSubscriber;
|
||||||
import akka.util.ByteString;
|
import akka.util.ByteString;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CompletionStage;
|
import java.util.concurrent.CompletionStage;
|
||||||
|
|
||||||
public class FromSinkAndSource {
|
public class FromSinkAndSource {
|
||||||
|
|
@ -31,7 +33,15 @@ public class FromSinkAndSource {
|
||||||
Flow<ByteString, ByteString, NotUsed> serverFlow = Flow.fromSinkAndSource(sink, source);
|
Flow<ByteString, ByteString, NotUsed> serverFlow = Flow.fromSinkAndSource(sink, source);
|
||||||
|
|
||||||
Source<Tcp.IncomingConnection, CompletionStage<Tcp.ServerBinding>> connectionStream =
|
Source<Tcp.IncomingConnection, CompletionStage<Tcp.ServerBinding>> connectionStream =
|
||||||
Tcp.get(system).bind("127.0.0.1", 9999);
|
Tcp.get(system)
|
||||||
|
.bind(
|
||||||
|
"127.0.0.1", // interface
|
||||||
|
9999, // port
|
||||||
|
100, // backlog
|
||||||
|
Collections.emptyList(), // socket options
|
||||||
|
true, // Important: half close enabled
|
||||||
|
Optional.empty() // idle timeout
|
||||||
|
);
|
||||||
|
|
||||||
connectionStream.runForeach(
|
connectionStream.runForeach(
|
||||||
incomingConnection -> incomingConnection.handleWith(serverFlow, system), system);
|
incomingConnection -> incomingConnection.handleWith(serverFlow, system), system);
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ object FromSinkAndSource {
|
||||||
|
|
||||||
val serverFlow = Flow.fromSinkAndSource(sink, source)
|
val serverFlow = Flow.fromSinkAndSource(sink, source)
|
||||||
|
|
||||||
Tcp().bind("127.0.0.1", 9999).runForeach { incomingConnection =>
|
Tcp().bind("127.0.0.1", 9999, halfClose = true).runForeach { incomingConnection =>
|
||||||
incomingConnection.handleWith(serverFlow)
|
incomingConnection.handleWith(serverFlow)
|
||||||
}
|
}
|
||||||
// #halfClosedTcpServer
|
// #halfClosedTcpServer
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue