Skip to content

Commit

Permalink
chore: Add the missing EmptySource case to TraversalBuilder (#1743)
Browse files Browse the repository at this point in the history
  • Loading branch information
He-Pin authored Jan 24, 2025
1 parent 864777e commit ba639f6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import org.apache.pekko
import pekko.NotUsed
import pekko.stream._
import pekko.stream.impl.TraversalTestUtils._
import pekko.stream.scaladsl.Keep
import pekko.stream.scaladsl.{ Keep, Source }
import pekko.testkit.PekkoSpec

class TraversalBuilderSpec extends PekkoSpec {
Expand Down Expand Up @@ -447,4 +447,20 @@ class TraversalBuilderSpec extends PekkoSpec {
}
}

"find Source.empty via TraversalBuilder with isEmptySource" in {
val emptySource = EmptySource
TraversalBuilder.isEmptySource(emptySource) should be(true)
}

"find javadsl Source.empty via TraversalBuilder with isEmptySource" in {
import pekko.stream.javadsl.Source
val emptySource = Source.empty()
TraversalBuilder.isEmptySource(emptySource) should be(true)
}

"find scaldsl Source.empty via TraversalBuilder with isEmptySource" in {
val emptySource = Source.empty
TraversalBuilder.isEmptySource(emptySource) should be(true)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ import pekko.util.unused
def isEmptySource(graph: Graph[SourceShape[_], _]): Boolean = graph match {
case source: scaladsl.Source[_, _] if source eq scaladsl.Source.empty => true
case source: javadsl.Source[_, _] if source eq javadsl.Source.empty() => true
case EmptySource => true
case _ => false
}

Expand Down

0 comments on commit ba639f6

Please sign in to comment.