You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "He-Pin (via GitHub)" <gi...@apache.org> on 2026/03/13 20:44:10 UTC
[PR] fix: Source.combine bypassing fanInStrategy for single source [pekko]
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: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] fix: Source.combine bypassing fanInStrategy for single source [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on PR #2726:
URL: https://github.com/apache/pekko/pull/2726#issuecomment-4063155460
I will try to add a trait to see if I can come up a better result
--
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: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] fix: Source.combine bypassing fanInStrategy for single source [pekko]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #2726:
URL: https://github.com/apache/pekko/pull/2726#issuecomment-4063219802
@He-Pin this is marked as Draft. Is it ready to merge? I'd like back port this to the 1.5.0 RC.
--
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: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] fix: Source.combine bypassing fanInStrategy for single source [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on PR #2726:
URL: https://github.com/apache/pekko/pull/2726#issuecomment-4063225817
Not really I will come up with a better design
--
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: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] fix(stream): Source.combine single source with type-transforming fan-in strategies [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on PR #2726:
URL: https://github.com/apache/pekko/pull/2726#issuecomment-4064312847
It's now better with a marker trait
--
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: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] fix(stream): Source.combine single source with type-transforming fan-in strategies [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin merged PR #2726:
URL: https://github.com/apache/pekko/pull/2726
--
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: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org