pekko icon indicating copy to clipboard operation
pekko copied to clipboard

stream-testkit: issue with scala 2.12 usage of expectNextWithTimeoutPF

Open pjfanning opened this issue 1 year ago • 9 comments

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 avatar Jul 12 '24 16:07 pjfanning

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

pjfanning avatar Jul 12 '24 16:07 pjfanning

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

He-Pin avatar Jul 12 '24 17:07 He-Pin

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

  • removing the Java API expectNextWithTimeoutPF
  • or changing the Java API expectNextWithTimeoutPF to use a Java function.

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?

pjfanning avatar Jul 13 '24 07:07 pjfanning

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

He-Pin avatar Jul 13 '24 08:07 He-Pin

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?

pjfanning avatar Jul 13 '24 09:07 pjfanning

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

He-Pin avatar Jul 13 '24 10:07 He-Pin

@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

pjfanning avatar Jul 19 '24 10:07 pjfanning

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

raboof avatar Jul 29 '24 15:07 raboof

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

pjfanning avatar Jul 29 '24 16:07 pjfanning