raboof commented on issue #2093:
URL: https://github.com/apache/pekko/issues/2093#issuecomment-3223313512

   > > I'm not at all sure that I like a major refactor just because a Java 
friendly terminate isn't implemented.
   
   I'm still skeptical as well - I suspect consistently splitting ActorSystem 
into a javadsl and a scaladsl variant will uncover some tricky situations and 
we'll have to carefully consider whether these are 'worth it' - but can't hurt 
to give it a try. Just don't get tunnel-visioned into this experiment.
   
   I think `ActorSystem` is 'special' enough that it's OK to be a bit different 
from the rest, and it's not the only class that is shared between java and 
scala dsl. 
   
   > > Can we at least review the API on the typed ActorSystem which is 
different from the class ActorSystem? The diff being that terminate returns 
void/unit. And then users need to call getWhenTerminated() (Java) or 
whenTerminated() (Scala) to get a CompletionStage or Future as required. These 
2 methods are on the classic ActorSystem too.
   > 
   > The thing is its not just `terminate` that returns a `Future`, as you 
stated there is also `whenTerminated` but that is still sticking out as a sore 
thumb.
   
   It's a well-established pattern that, for classes that are shared between 
javadsl and scaladsl, the Java API uses methods of the form 'getXxx' where the 
Scala API uses plain `xxx`. This is also documented as 
https://github.com/apache/pekko/blob/main/CONTRIBUTING.md#java-apis-in-pekko 
point 16. It's too bad that we don't have an equivalent for 'actions', but I 
don't see an obvious candidate.
   
   > But you are right in that I should look into the typed `ActorSystem` and 
see the reasoning/intent behind it returning `Void`/`Unit` (I guess they made 
that method blocking to make it easier to use, although if thats the case that 
is a not very akka/pekko like???)
   
   It's not blocking - the docs even say so ("This is an asynchronous operation 
and completion of the termination can be observed with 
[[ActorSystem.whenTerminated]] or [[ActorSystem.getWhenTerminated]]."). I 
suspect the return value was dropped in favor of those two getters precisely 
because this makes it possible to have separate Java and Scala APIs for 
watching the termination.
   
   Since we're thinking 2.0.0 anyway: perhaps `ActorSystem` should implement 
https://docs.oracle.com/javase/8/docs/api/java/io/Closeable.html, and 
`terminate` should be deprecated in favor of `close` and 
`whenTerminated`/`getWhenTerminated`.
    
   > Can we hold off on the 1.2.x release until I look into this properly?
   
   I don't see any reason for that.


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