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 d957aa9887 docs: update Scaladoc examples from Arrays.asList to 
List.of (#3140)
d957aa9887 is described below

commit d957aa98874da7bd07195cfbdb242c7f5558940b
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Tue Jun 23 20:06:55 2026 +0800

    docs: update Scaladoc examples from Arrays.asList to List.of (#3140)
    
    * docs: update Scaladoc examples from Arrays.asList to List.of
    
    Motivation:
    Scaladoc examples in the Stream Java DSL use Arrays.asList(...) which
    creates a mutable fixed-size list backed by an array.
    
    Modification:
    Replace with List.of(...) (JDK 9 factory) which returns a truly immutable
    list, consistent with modern Java best practices. Also updates the
    executable Graph.scala code where util.Arrays.asList was used.
    
    Result:
    Documentation examples use idiomatic JDK 9+ API.
    
    Tests:
    Not run - docs only (Scaladoc comments)
    
    References:
    Refs #3136
    
    * docs: fix mis-parenthesized interleave Scaladoc examples
    
    Motivation:
    While migrating `Arrays.asList` to `List.of` in the Stream Java DSL
    Scaladoc, two `interleave` examples were found with a misplaced
    closing parenthesis:
    
        .interleave(Source.from(List.of(4, 5, 6, 7), 2)
    
    Here the `2` (intended as the `interleave` breadth argument) was
    accidentally parsed as a second argument to `Source.from`, which
    does not accept one. The example would not compile as shown.
    
    Modification:
    Move the closing parenthesis so that `2` is passed to `interleave`:
    
        .interleave(Source.from(List.of(4, 5, 6, 7)), 2)
    
    The same correction is applied in both `Source.scala` and
    `SubSource.scala`. The corresponding `Flow.scala` example already
    had the correct parenthesization and is left unchanged.
    
    Result:
    Scaladoc code samples compile as written and accurately demonstrate
    the `interleave` operator.
    
    Tests:
    Not run - docs only (Scaladoc comment examples).
    
    References:
    Discovered during internal review of PR #3140.
    
    * docs: use List.of instead of mutable ArrayList wrapper in Graph.create 
Scaladoc
    
    Motivation:
    The mutable ArrayList wrapper around List.of was unnecessary since
    the toList function only creates a single-element list.
    
    Modification:
    Replace `new util.ArrayList(util.List.of(m1))` with `util.List.of(m1)`.
    
    Result:
    Simpler, more idiomatic code in the Scaladoc example.
    
    References:
    Refs #3140
---
 stream/src/main/scala/org/apache/pekko/stream/javadsl/Flow.scala  | 8 ++++----
 stream/src/main/scala/org/apache/pekko/stream/javadsl/Graph.scala | 2 +-
 .../src/main/scala/org/apache/pekko/stream/javadsl/Source.scala   | 8 ++++----
 .../src/main/scala/org/apache/pekko/stream/javadsl/SubFlow.scala  | 4 ++--
 .../main/scala/org/apache/pekko/stream/javadsl/SubSource.scala    | 6 +++---
 5 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/stream/src/main/scala/org/apache/pekko/stream/javadsl/Flow.scala 
b/stream/src/main/scala/org/apache/pekko/stream/javadsl/Flow.scala
index 5a889b6189..512b8ac022 100755
--- a/stream/src/main/scala/org/apache/pekko/stream/javadsl/Flow.scala
+++ b/stream/src/main/scala/org/apache/pekko/stream/javadsl/Flow.scala
@@ -1621,7 +1621,7 @@ final class Flow[In, Out, Mat](delegate: 
scaladsl.Flow[In, Out, Mat]) extends Gr
    * Examples:
    *
    * {{{
-   * Source<Integer, ?> nums = Source.from(Arrays.asList(0, 1, 2, 3));
+   * Source<Integer, ?> nums = Source.from(List.of(0, 1, 2, 3));
    * nums.intersperse(",");            //   1 , 2 , 3
    * nums.intersperse("[", ",", "]");  // [ 1 , 2 , 3 ]
    * }}}
@@ -1655,7 +1655,7 @@ final class Flow[In, Out, Mat](delegate: 
scaladsl.Flow[In, Out, Mat]) extends Gr
    * Examples:
    *
    * {{{
-   * Source<Integer, ?> nums = Source.from(Arrays.asList(0, 1, 2, 3));
+   * Source<Integer, ?> nums = Source.from(List.of(0, 1, 2, 3));
    * nums.intersperse(",");            //   1 , 2 , 3
    * nums.intersperse("[", ",", "]");  // [ 1 , 2 , 3 ]
    * }}}
@@ -3390,8 +3390,8 @@ final class Flow[In, Out, Mat](delegate: 
scaladsl.Flow[In, Out, Mat]) extends Gr
    *
    * Example:
    * {{{
-   * Source<Integer, ?> src = Source.from(Arrays.asList(1, 2, 3))
-   * Flow<Integer, Integer, ?> flow = 
flow.interleave(Source.from(Arrays.asList(4, 5, 6, 7)), 2)
+   * Source<Integer, ?> src = Source.from(List.of(1, 2, 3))
+   * Flow<Integer, Integer, ?> flow = flow.interleave(Source.from(List.of(4, 
5, 6, 7)), 2)
    * src.via(flow) // 1, 2, 4, 5, 3, 6, 7
    * }}}
    *
diff --git a/stream/src/main/scala/org/apache/pekko/stream/javadsl/Graph.scala 
b/stream/src/main/scala/org/apache/pekko/stream/javadsl/Graph.scala
index ba9264a8b9..4af7893d3f 100644
--- a/stream/src/main/scala/org/apache/pekko/stream/javadsl/Graph.scala
+++ b/stream/src/main/scala/org/apache/pekko/stream/javadsl/Graph.scala
@@ -726,7 +726,7 @@ object GraphDSL extends GraphCreate {
       : Graph[S, java.util.List[M]] = {
     require(!graphs.isEmpty, "The input list must have one or more Graph 
elements")
     val gbuilder = builder[java.util.List[M]]()
-    val toList = (m1: M) => new util.ArrayList(util.Arrays.asList(m1))
+    val toList = (m1: M) => util.List.of(m1)
     val combine = (s: java.util.List[M], m2: M) => {
       val newList = new util.ArrayList(s)
       newList.add(m2)
diff --git a/stream/src/main/scala/org/apache/pekko/stream/javadsl/Source.scala 
b/stream/src/main/scala/org/apache/pekko/stream/javadsl/Source.scala
index e60a445e62..e6ed914a8e 100755
--- a/stream/src/main/scala/org/apache/pekko/stream/javadsl/Source.scala
+++ b/stream/src/main/scala/org/apache/pekko/stream/javadsl/Source.scala
@@ -128,7 +128,7 @@ object Source {
    * Example usage:
    *
    * {{{
-   * Source.cycle(() -> Arrays.asList(1, 2, 3).iterator());
+   * Source.cycle(() -> List.of(1, 2, 3).iterator());
    * }}}
    *
    * Start a new 'cycled' `Source` from the given elements. The producer 
stream of elements
@@ -1514,7 +1514,7 @@ final class Source[Out, Mat](delegate: 
scaladsl.Source[Out, Mat]) extends Graph[
    *
    * Example:
    * {{{
-   * Source.from(Arrays.asList(1, 2, 
3)).interleave(Source.from(Arrays.asList(4, 5, 6, 7), 2)
+   * Source.from(List.of(1, 2, 3)).interleave(Source.from(List.of(4, 5, 6, 
7)), 2)
    * // 1, 2, 4, 5, 3, 6, 7
    * }}}
    *
@@ -3504,7 +3504,7 @@ final class Source[Out, Mat](delegate: 
scaladsl.Source[Out, Mat]) extends Graph[
    * Examples:
    *
    * {{{
-   * Source<Integer, ?> nums = Source.from(Arrays.asList(0, 1, 2, 3));
+   * Source<Integer, ?> nums = Source.from(List.of(0, 1, 2, 3));
    * nums.intersperse(",");            //   1 , 2 , 3
    * nums.intersperse("[", ",", "]");  // [ 1 , 2 , 3 ]
    * }}}
@@ -3537,7 +3537,7 @@ final class Source[Out, Mat](delegate: 
scaladsl.Source[Out, Mat]) extends Graph[
    * Examples:
    *
    * {{{
-   * Source<Integer, ?> nums = Source.from(Arrays.asList(0, 1, 2, 3));
+   * Source<Integer, ?> nums = Source.from(List.of(0, 1, 2, 3));
    * nums.intersperse(",");            //   1 , 2 , 3
    * nums.intersperse("[", ",", "]");  // [ 1 , 2 , 3 ]
    * }}}
diff --git 
a/stream/src/main/scala/org/apache/pekko/stream/javadsl/SubFlow.scala 
b/stream/src/main/scala/org/apache/pekko/stream/javadsl/SubFlow.scala
index 0082bf73d5..e2a1644e12 100755
--- a/stream/src/main/scala/org/apache/pekko/stream/javadsl/SubFlow.scala
+++ b/stream/src/main/scala/org/apache/pekko/stream/javadsl/SubFlow.scala
@@ -1013,7 +1013,7 @@ final class SubFlow[In, Out, Mat](
    * Examples:
    *
    * {{{
-   * Source<Integer, ?> nums = Source.from(Arrays.asList(0, 1, 2, 3));
+   * Source<Integer, ?> nums = Source.from(List.of(0, 1, 2, 3));
    * nums.intersperse(",");            //   1 , 2 , 3
    * nums.intersperse("[", ",", "]");  // [ 1 , 2 , 3 ]
    * }}}
@@ -1047,7 +1047,7 @@ final class SubFlow[In, Out, Mat](
    * Examples:
    *
    * {{{
-   * Source<Integer, ?> nums = Source.from(Arrays.asList(0, 1, 2, 3));
+   * Source<Integer, ?> nums = Source.from(List.of(0, 1, 2, 3));
    * nums.intersperse(",");            //   1 , 2 , 3
    * nums.intersperse("[", ",", "]");  // [ 1 , 2 , 3 ]
    * }}}
diff --git 
a/stream/src/main/scala/org/apache/pekko/stream/javadsl/SubSource.scala 
b/stream/src/main/scala/org/apache/pekko/stream/javadsl/SubSource.scala
index 18ad5712bc..c756c91c56 100755
--- a/stream/src/main/scala/org/apache/pekko/stream/javadsl/SubSource.scala
+++ b/stream/src/main/scala/org/apache/pekko/stream/javadsl/SubSource.scala
@@ -999,7 +999,7 @@ final class SubSource[Out, Mat](
    * Examples:
    *
    * {{{
-   * Source<Integer, ?> nums = Source.from(Arrays.asList(0, 1, 2, 3));
+   * Source<Integer, ?> nums = Source.from(List.of(0, 1, 2, 3));
    * nums.intersperse(",");            //   1 , 2 , 3
    * nums.intersperse("[", ",", "]");  // [ 1 , 2 , 3 ]
    * }}}
@@ -1033,7 +1033,7 @@ final class SubSource[Out, Mat](
    * Examples:
    *
    * {{{
-   * Source<Integer, ?> nums = Source.from(Arrays.asList(0, 1, 2, 3));
+   * Source<Integer, ?> nums = Source.from(List.of(0, 1, 2, 3));
    * nums.intersperse(",");            //   1 , 2 , 3
    * nums.intersperse("[", ",", "]");  // [ 1 , 2 , 3 ]
    * }}}
@@ -2354,7 +2354,7 @@ final class SubSource[Out, Mat](
    *
    * Example:
    * {{{
-   * Source.from(Arrays.asList(1, 2, 
3)).interleave(Source.from(Arrays.asList(4, 5, 6, 7), 2)
+   * Source.from(List.of(1, 2, 3)).interleave(Source.from(List.of(4, 5, 6, 
7)), 2)
    * // 1, 2, 4, 5, 3, 6, 7
    * }}}
    *


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

Reply via email to