This is an automated email from the ASF dual-hosted git repository.

hepin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-pekko.git


The following commit(s) were added to refs/heads/main by this push:
     new 781b1226e7 =str Optimize concat for javadsl.Source.empty.
781b1226e7 is described below

commit 781b1226e7bf1e9906658a56304af4eb466cfe42
Author: He-Pin <[email protected]>
AuthorDate: Sat Dec 23 18:34:40 2023 +0800

    =str Optimize concat for javadsl.Source.empty.
---
 .../test/java/org/apache/pekko/stream/javadsl/SourceTest.java | 11 +++++++++++
 .../main/scala/org/apache/pekko/stream/scaladsl/Flow.scala    |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git 
a/stream-tests/src/test/java/org/apache/pekko/stream/javadsl/SourceTest.java 
b/stream-tests/src/test/java/org/apache/pekko/stream/javadsl/SourceTest.java
index 7849921b5d..e589f14588 100644
--- a/stream-tests/src/test/java/org/apache/pekko/stream/javadsl/SourceTest.java
+++ b/stream-tests/src/test/java/org/apache/pekko/stream/javadsl/SourceTest.java
@@ -286,6 +286,17 @@ public class SourceTest extends StreamTest {
     assertEquals(Arrays.asList("A", "B", "C", "D", "E", "F"), output);
   }
 
+  @Test
+  public void mustBeAbleToConcatEmptySource() {
+    Source.from(Arrays.asList("A", "B", "C"))
+        .concat(Source.empty())
+        .runWith(TestSink.probe(system), system)
+        .ensureSubscription()
+        .request(3)
+        .expectNext("A", "B", "C")
+        .expectComplete();
+  }
+
   @Test
   public void mustBeAbleToUseConcatAll() {
     final Source<Integer, NotUsed> sourceA = Source.from(Arrays.asList(1, 2, 
3));
diff --git a/stream/src/main/scala/org/apache/pekko/stream/scaladsl/Flow.scala 
b/stream/src/main/scala/org/apache/pekko/stream/scaladsl/Flow.scala
index de4c81e493..1d219559aa 100755
--- a/stream/src/main/scala/org/apache/pekko/stream/scaladsl/Flow.scala
+++ b/stream/src/main/scala/org/apache/pekko/stream/scaladsl/Flow.scala
@@ -3302,7 +3302,7 @@ trait FlowOps[+Out, +Mat] {
 
   private def internalConcat[U >: Out, Mat2](that: Graph[SourceShape[U], 
Mat2], detached: Boolean): Repr[U] =
     that match {
-      case source if source eq Source.empty => this.asInstanceOf[Repr[U]]
+      case source if TraversalBuilder.isEmptySource(source) => 
this.asInstanceOf[Repr[U]]
       case other =>
         TraversalBuilder.getSingleSource(other) match {
           case OptionVal.Some(singleSource) =>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to