Skip to content

Conversation

@He-Pin
Copy link
Member

@He-Pin He-Pin commented Dec 6, 2025

This should be removed from javadsl

Deprecated for #2555

@He-Pin He-Pin added this to the 2.0.0-M1 milestone Dec 6, 2025
@mdedetrich
Copy link
Contributor

Was this deprecated in the 1.x series of Pekko?

@He-Pin He-Pin force-pushed the dropFutureSourceInJava branch from fa68d01 to 1e3b98f Compare December 6, 2025 09:56
@He-Pin
Copy link
Member Author

He-Pin commented Dec 6, 2025

@mdedetrich I will deprecate it in the 1.4.x with another pr

@He-Pin He-Pin added the t:stream Pekko Streams label Dec 6, 2025
@He-Pin He-Pin force-pushed the dropFutureSourceInJava branch from ddbde72 to 5fb7cd7 Compare December 6, 2025 10:35
@pjfanning
Copy link
Member

Was this deprecated in the 1.x series of Pekko?

That is my point. The code is not yet deprecated and I think there is a good chance that Java users have been using it.
I don't see why we can't leave the method alone and maybe just add a javadoc mention of more Java friendly methods that we also support.

It causes us zero overhead to maintain the existing method.

@He-Pin He-Pin marked this pull request as draft December 6, 2025 12:11
@He-Pin He-Pin removed this from the 2.0.0-M1 milestone Dec 6, 2025
@mdedetrich
Copy link
Contributor

That is my point. The code is not yet deprecated and I think there is a good chance that Java users have been using it. I don't see why we can't leave the method alone and maybe just add a javadoc mention of more Java friendly methods that we also support.

It causes us zero overhead to maintain the existing method.

While I agree that the PR to deprecate the method should land first in Pekko 1.x series, leaving around the method in 2.0.x series is likely going to be pointless/useless because the only reason it exists is due to deficiencies in the current 1.x Pekko API where it leaks the usage of Scala futures to javaapi, a lot of which is actually fixed in 2.0.x series.

Actual Java users don't like and don't want to use Scala's future, and I would be shocked if anyone is actually using these methods aside from the usecase I described ergo some javadsl returning/accepting a Scala future when it should instead be using CompletionStage.

@He-Pin
Copy link
Member Author

He-Pin commented Dec 8, 2025

@mdedetrich Me too, as Java developer using Scala's future is a bit wired

@pjfanning
Copy link
Member

Even if we deprecate Java DSL Source.future, we don't yet have a release with the deprecation notice so I think this PR is getting well ahead of itself. Let's deprecate, get a release with the deprecation and see if there is any feedback before removing the method.

@raboof
Copy link
Member

raboof commented Dec 8, 2025

As the javadoc says, this function is "Here for Java interoperability, the normal use from Java should be [[Source.completionStage]]". Ideally a 'healthy' codebase should likely not need this method, and use CompletionStage consistently. Indeed we've been making nice progress towards making that possible in Pekko itself for 2.0.0.

There might be places where we still only produce Future, and more importantly, people might be using 3rd-party or in-house components that provide Futures. Actual Java users indeed don't like and don't want to use Scala's future, but IMHO that means we should have good interoperability helpers, rather than making it even harder for those Java devs that inevitably find themselves having to deal with a Future due to other constraints.

In this case AFAICS FutureConverters.asJava provides a simple drop-in replacement making this helper superfluous. For this reason I'd support deprecating in 1.x and removing already in 2.0.0: even if we discover cases where it is still hard to avoid a Future, we can direct people to FutureConverters.asJava and Source.completionStage.

I'm not sure I think we should wait for a 1.x release with the deprecation before merging this PR, but I agree there's a risk we'd forget the deprecation, so I agree it would be good to get the deprecation in 1.x merged before we merge the removal for 2.x.

@He-Pin
Copy link
Member Author

He-Pin commented Dec 8, 2025

Yes, it would be nice if we had a 1.5.x during the release cycle of 2.0.0

@mdedetrich
Copy link
Contributor

As the javadoc says, this function is "Here for Java interoperability, the normal use from Java should be [[Source.completionStage]]". Ideally a 'healthy' codebase should likely not need this method, and use CompletionStage consistently. Indeed we've been making nice progress towards making that possible in Pekko itself for 2.0.0.

There might be places where we still only produce Future, and more importantly, people might be using 3rd-party or in-house components that provide Futures. Actual Java users indeed don't like and don't want to use Scala's future, but IMHO that means we should have good interoperability helpers, rather than making it even harder for those Java devs that inevitably find themselves having to deal with a Future due to other constraints.

The big remaining issue here is ActorSystem but that is something that I will now look into given that 2.0.0-M1 is out.

In this case AFAICS FutureConverters.asJava provides a simple drop-in replacement making this helper superfluous. For this reason I'd support deprecating in 1.x and removing already in 2.0.0: even if we discover cases where it is still hard to avoid a Future, we can direct people to FutureConverters.asJava and Source.completionStage.

Yes this is exactly the point, there already are future/completion stage converters that are part of Scala's stdlib for Scala 2.13+, including ones that are designs to be called within Java (converting Future to CompletionStage). Actually our codebase uses them frequently throughout, and we use those Future to CompletionStage converters in our Java tests (often because of these aforementioned uses of Future in Java APIs that we are gradually fixing)

I'm not sure I think we should wait for a 1.x release with the deprecation before merging this PR, but I agree there's a risk we'd forget the deprecation, so I agree it would be good to get the deprecation in 1.x merged before we merge the removal for 2.x.

I will approve PR once the deprecation lands in 1.4.x Pekko.

@He-Pin He-Pin marked this pull request as ready for review December 14, 2025 05:50
@He-Pin He-Pin force-pushed the dropFutureSourceInJava branch from 5fb7cd7 to 89bd15c Compare December 14, 2025 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t:stream Pekko Streams

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants