Skip to content

Commit

Permalink
Fix unserializable restart message in ClientSupervisor.
Browse files Browse the repository at this point in the history
Signed-off-by: Yufei Cai <yufei.cai@bosch.io>
  • Loading branch information
yufei-cai committed Dec 5, 2022
1 parent 821aac4 commit 3dcc960
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public final class ClientSupervisor extends AbstractActorWithTimers {
private final ActorRef connectionShardRegion;
private final ClientActorPropsFactory propsFactory;
private Props props;
private ClientActorPropsArgs clientActorPropsArgs;
private ActorRef clientActor;

@SuppressWarnings({"unused"})
Expand Down Expand Up @@ -158,6 +159,7 @@ private void startClientActor(final ClientActorPropsArgs propsArgs) {
getContext().stop(oldClientActor);
}
this.props = actorProps;
this.clientActorPropsArgs = propsArgs;
clientActor = getContext().watch(getContext().actorOf(actorProps));
logger.debug("New actorProps received; stopped client actor <{}> and started <{}>", oldClientActor,
clientActor);
Expand Down Expand Up @@ -207,9 +209,9 @@ private void respondAndStop(final CloseConnection command) {
}

private void restartIfOpen(final StopShardedActor stopShardedActor) {
if (props != null) {
if (clientActorPropsArgs != null) {
logger.debug("Restarting connected client actor.");
final var envelope = new ShardedBinaryEnvelope(props, clientActorId.toString());
final var envelope = new ShardedBinaryEnvelope(clientActorPropsArgs, clientActorId.toString());
ClusterSharding.get(getContext().getSystem())
.shardRegion(ConnectivityMessagingConstants.CLIENT_SHARD_REGION)
.tell(envelope, ActorRef.noSender());
Expand Down

0 comments on commit 3dcc960

Please sign in to comment.