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

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


The following commit(s) were added to refs/heads/main by this push:
     new 44e2aaecae test: make InputStreamSource TCK publisher finite (#2999)
44e2aaecae is described below

commit 44e2aaecaed37d03f0f82d736cad2e885e370ff7
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Wed Jun 24 22:01:42 2026 +0800

    test: make InputStreamSource TCK publisher finite (#2999)
    
    Motivation:
    JDK 25 nightly builds abort InputStreamSourceTest when the TCK cancellation 
scenario waits for completion from an infinite, CPU-busy InputStream publisher.
    
    Modification:
    Make the test publisher finite and emit one byte per ByteString so the TCK 
element count maps directly to stream elements without relying on 
take(elements) to stop a busy reader.
    
    Result:
    InputStreamSourceTest completes under JDK 25 nightly-style virtualized 
stream-dispatcher settings.
    
    Tests:
    - JDK 25 nightly-style virtualized stream-dispatcher flags: 
stream-tests-tck / Test / testOnly 
org.apache.pekko.stream.tck.InputStreamSourceTest
    - scalafmt --mode diff-ref=origin/main --quiet
    - scalafmt --list --mode diff-ref=origin/main
    - git diff --check
    
    References:
    Refs #2994
---
 .../pekko/stream/tck/InputStreamSourceTest.scala    | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git 
a/stream-tests-tck/src/test/scala/org/apache/pekko/stream/tck/InputStreamSourceTest.scala
 
b/stream-tests-tck/src/test/scala/org/apache/pekko/stream/tck/InputStreamSourceTest.scala
index bc54abba43..1c2dad2ba4 100644
--- 
a/stream-tests-tck/src/test/scala/org/apache/pekko/stream/tck/InputStreamSourceTest.scala
+++ 
b/stream-tests-tck/src/test/scala/org/apache/pekko/stream/tck/InputStreamSourceTest.scala
@@ -25,17 +25,20 @@ import org.reactivestreams.Publisher
 class InputStreamSourceTest extends PekkoPublisherVerification[ByteString] {
 
   def createPublisher(elements: Long): Publisher[ByteString] = {
+    def inputStream = new InputStream {
+      private var remaining = elements
+      override def read(): Int = {
+        if (remaining > 0) {
+          remaining -= 1
+          1
+        } else -1
+      }
+    }
+
     StreamConverters
-      .fromInputStream(() =>
-        new InputStream {
-          @volatile var num = 0
-          override def read(): Int = {
-            num += 1
-            num
-          }
-        })
+      // The TCK counts publisher elements, so emit one byte per ByteString.
+      .fromInputStream(() => inputStream, chunkSize = 1)
       
.withAttributes(ActorAttributes.dispatcher("pekko.test.stream-dispatcher"))
-      .take(elements)
       .runWith(Sink.asPublisher(false))
   }
 }


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

Reply via email to