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

   > [@mdedetrich](https://github.com/mdedetrich) 
[@raboof](https://github.com/raboof) [@He-Pin](https://github.com/He-Pin) My 
view is that it's not very useful to make changes. Java users can ignore the 
return value on the class ActorSystem terminate() call and then use the 
getWhenTerminated() method to get a CompletionStage to check. This maps closely 
to what they would do with the typed ActorSystem too (where terminate() returns 
a void anyway).
   
   Ignoring the `Future` from `.terminate()` call shouldn't be encouraged, 
because if you need to do something after the Actor termination then the 
termination will only occur successful when that `Future` completes.
   
   When using the java API I actually have to use `.toCompletableFuture()` 
because of this, i.e.
   
   ```kotlin
   fun shutdown() {
       logger.info("Terminating actor system")
       
FutureConverters.asJava(system.terminate()).toCompletableFuture().whenComplete 
{ _, exception ->
           if (exception != null) {
               logger.warn("Error terminating actor system", exception)
           } else
               logger.info("Terminated actor system")
       }.get()
   }
   ```
   
   Its also not consistent, i.e. if you are using pekko http its standard 
practice to terminate the actor system after you terminate the http server, 
where again you have to call the `.toCompletableFuture()` method when using 
java api
   
   ```kotlin
   serverBinding.terminate(Duration.ofSeconds(10)).thenCompose {
     FutureConverters.asJava(system.terminate()).toCompletableFuture()
   }
   ```
   
   its all really quite ugly, I would personally push to have a proper 
`terminate` method for the Java API which returns a `CompletableFuture`. 2.0.x 
allows for breaking changes, so now is the opportunity to do such a change
   
   


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