- TestActorRef<T> actorRef = TestActorRef.create(system, props, actorId);
- return (TestActorRef<T>) addActor(actorRef, true);
+ InvalidActorNameException lastError = null;
+ for (int i = 0; i < 10; i++) {
+ try {
+ TestActorRef<T> actorRef = TestActorRef.create(system, props, actorId);
+ return (TestActorRef<T>) addActor(actorRef, true);
+ } catch (InvalidActorNameException e) {
+ lastError = e;
+ Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ }
+ }
+
+ throw lastError;