apache / pekko

Build highly concurrent, distributed, and resilient message-driven applications using Java/Scala
https://pekko.apache.org/
Apache License 2.0
1.17k stars 140 forks source link

stream-testkit: issue with scala 2.12 usage of expectNextWithTimeoutPF #1393

Open pjfanning opened 2 months ago

pjfanning commented 2 months ago

see https://github.com/apache/pekko-persistence-cassandra/pull/212 there change that seems to have caused the issue is #1218 (and earlier #1186)

pjfanning commented 2 months ago

@He-Pin what do you think we should do here? Should we document the issue we see in https://github.com/apache/pekko-persistence-cassandra/pull/212 or is there a change we can make to stream-testkit to avoid the issue going forward?

He-Pin commented 2 months ago

I was expected to avoid a double evaluation, but that can only be done with 2.13, we may better go with 2.13 abd I expect drop the 2.12 support in 1.2.x anyway

pjfanning commented 2 months ago

@He-Pin This new method in https://github.com/He-Pin/incubator-pekko/blob/05248075bd13a336c9af079cb44a61986dc1f751/stream-testkit/src/main/scala/org/apache/pekko/stream/testkit/StreamTestKit.scala#L869 doesn't make sense to me. The PartialFunction is a Scala function, not a Java function. This seems like a not very useful Java API. The other changes in #1186 seem mainly ok to me but could we consider these?

When I say the other changes in #1186 are mainly ok, there are other new Java API methods that take Scala Partial Functions as inputs.

How do Java users even create a Scala Partial Function?

He-Pin commented 2 months ago

Yes, but a user can build a PartialFunction with the helper, such as the Receive builder.

pjfanning commented 2 months ago

Yes, but a user can build a PartialFunction with the helper, such as the Receive builder.

The ReceiveBuilder will not work for this stream-testkit use case. Unless we have a builder that can build a PartialFunction[Any, T] - does that exist?

He-Pin commented 2 months ago

@pjfanning Yes, org.apache.pekko.japi.pf.PFBuilder.

pjfanning commented 1 month ago

@pjfanning Yes, org.apache.pekko.japi.pf.PFBuilder.

Thanks - there seem to be some useful classes in the org.apache.pekko.japi.pf package.

https://pekko.apache.org/japi/pekko/current/org/apache/pekko/japi/pf/package-summary.html

raboof commented 1 month ago

@He-Pin what do you think we should do here? Should we document the issue we see in apache/pekko-persistence-cassandra#212 or is there a change we can make to stream-testkit to avoid the issue going forward?

If I understand correctly this is only an issue when using Scala 2.12, right? In that case I think the note in #1403 seems sufficient and IMHO we can close this issue (or keep it open for if anyone is interested in looking into it, but remove it from the 1.1.0 milestone)

pjfanning commented 1 month ago

I'll close this. It is documented and I think the consensus is not to fix it.