He-Pin opened a new pull request, #2726:
URL: https://github.com/apache/pekko/pull/2726

   ## Motivation
   
   `Source.combine` with a single source bypasses the `fanInStrategy` entirely, 
performing a direct `asInstanceOf` cast. This is incorrect for strategies like 
`MergeLatest` where the output type differs from the input type (`T => 
List[T]`).
   
   For example:
   ```scala
   Source.combine(Seq(Source.single(1)))(MergeLatest(_))
   // Expected: emits List(1)
   // Actual: emits 1 (raw Int, ClassCastException at runtime)
   ```
   
   ## Modification
   
   - Try `fanInStrategy(1)` first via GraphDSL, routing through the strategy 
even for a single source
   - If the strategy throws `IllegalArgumentException` (e.g., 
`Concat`/`Interleave` which require >1 inputs), fall back to the original 
direct cast behavior (safe because those strategies always have `T == U`)
   - Added 4 Scala tests and 1 Java test covering `MergeLatest`, `Merge`, and 
`Concat` with single source
   
   ## Result
   
   `Source.combine(Seq(source))(MergeLatest(_))` now correctly emits `List[T]` 
instead of raw `T`. Existing behavior for `Merge`, `Concat`, etc. is preserved.
   
   ## References
   
   - Fixes https://github.com/apache/pekko/issues/2723


-- 
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