vlingo / xoom-actors

The VLINGO XOOM platform SDK for the type-safe Actor Model, delivering Reactive concurrency, high scalability, high-throughput, and resiliency using Java and other JVM languages.
https://vlingo.io
Mozilla Public License 2.0
229 stars 28 forks source link

Stage.actorOf(Class, Address) returns a success Completes<T> with a null value when the actor does not exist #43

Closed kmruiz closed 5 years ago

kmruiz commented 5 years ago

Right now, it's returning a null value that is hard to handle because you can have either null or an actor reference. With the current BasicCompletes implementation, if any of the andThen, andThenTo steps fail with a NPE, neither otherwise or recoverFrom are called. During a HTTP Request, the client wouldn't get any answer.

How to reproduce

  1. Create a World instance
  2. Call world.stage().actorOf(AnyClass, NonExistingAddress)
  3. Try to recover with either otherwise or recoverFrom
  4. Use andThen to map the value
VaughnVernon commented 5 years ago

@kmruiz This should be fixed/improved by some changes in both io.vlingo.common.BasicCompletes as well as io.vlingo.actors.Stage and io.vlingo.actors.DirectoryScannerActor. Please confirm. If it is not fixed please provide a test that fails so I can make it green.

The main "fix" here is in part to recognize that a null is always a failure value. If there is any code that considers null to be a valid outcome it must be changed to provide a different value of the T type.

kmruiz commented 5 years ago

We can assume that null will be always a failure. For representing an abscense of a value, we can use Optional or even we can use null objects 😄

VaughnVernon commented 5 years ago

Implemented maybeActorOf() that returns Completes<Optional<T>>.

kmruiz commented 5 years ago

We can close it then 👍 . Thanks!