pjfanning opened a new pull request, #3713:
URL: https://github.com/apache/pekko/pull/3713

   ### Motivation
   Java generics are invariant, so several javadsl parameters reject values a 
Java user would reasonably pass, for example:
   
   - a `List<Source<T, NotUsed>>` variable where `List<Source<T, ?>>` is 
expected (`Source.zipN`, `Source.combine`, ...)
   - a `List<ItemAdded>` where `List<Event>` is expected 
(`Effect().persist(...)`)
   - a `Function<Out, List<T>>` where `Function<Out, Iterable<T>>` is expected 
(`mapConcat`)
   - a `PartialFunction<Throwable, Source<Out, NotUsed>>` built with 
`PFBuilder` (`recoverWith` on `SubFlow` / `SubSource`)
   
   The same operators were also bounded inconsistently across `Source`, `Flow`, 
`SubFlow` and `SubSource`. Following the review in #3712, the collection 
parameters also now accept any `java.lang.Iterable` rather than only 
`java.util.List`.
   
   ### Modification
   - Take `java.lang.Iterable[? <: Graph[...]]` instead of `java.util.List` for 
javadsl collections of graphs: `Source.combine` (both overloads), `zipN`, 
`zipWithN`, `mergePrioritizedN` (`Iterable[? <: Pair[? <: Graph[...], 
Integer]]`), `Sink.combine` (both overloads), and `mergeAll` / `interleaveAll` 
on `Source`, `Flow`, `SubFlow` and `SubSource`.
   - Take `java.lang.Iterable[? <: Event]` in javadsl `Effect.persist`.
   - Add `? <:` bounds to the function results of `mapConcat`, 
`statefulMapConcat`, `recoverWith`, `recoverWithRetries` and the `combine` / 
`combineMat` fan-in and fan-out strategies, matching the sibling operators that 
already had them.
   - Add MiMa excludes for the changed signatures.
   
   ### Result
   Java callers can pass any `Iterable`, and pre-typed values with narrower 
generic types, without casts or re-typing.
   
   - **Java source compatibility** is preserved: every `List` is an `Iterable`, 
and widening parameters accepts everything that compiled before.
   - **Binary compatibility:** the `? <:` bounds only change generic 
signatures. The `List` → `Iterable` change alters the erased descriptors of the 
listed methods, so code compiled against 1.x that calls them must be 
recompiled. These are recorded as `IncompatibleMethTypeProblem` excludes for 
2.0.0.
   
   ### Tests
   - New Java tests in `SourceTest`, `FlowTest`, `SinkTest` and 
`EventSourcedBehaviorJavaDslTest` pass values with narrower generic types and 
non-`List` iterables (`ArrayDeque`). Against the `main` sources they fail to 
compile, with 40 errors in `stream-tests` and 1 in `persistence-typed-tests`.
   - `sbt "stream-tests/testOnly org.apache.pekko.stream.javadsl.SourceTest 
org.apache.pekko.stream.javadsl.SinkTest 
org.apache.pekko.stream.javadsl.FlowTest"`: 235 passed
   - `sbt "persistence-typed-tests/testOnly 
org.apache.pekko.persistence.typed.javadsl.EventSourcedBehaviorJavaDslTest"`: 
15 passed
   - `sbt "stream/mimaReportBinaryIssues" 
"persistence-typed/mimaReportBinaryIssues"`: passed with the added excludes
   - `scalafmt` and `javafmtAll` (JDK 17) run on the changed files
   
   ### References
   Refs #3712. The lower-priority candidates listed in 
https://github.com/apache/pekko/issues/3712#issuecomment-6421792710 are not 
covered here.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to