Skip to content

Commit 22315d7

Browse files
Remove test actor deadletter logging (#5662)
* Modernize Receive function to switch instead of if...else * Remove TestActor DeadLetter logging Co-authored-by: Gregorius Soedharmo <[email protected]>
1 parent 6eb81a1 commit 22315d7

File tree

1 file changed

+21
-46
lines changed

1 file changed

+21
-46
lines changed

src/core/Akka.TestKit/Internal/InternalTestActor.cs

Lines changed: 21 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -52,41 +52,30 @@ protected override bool Receive(object message)
5252
throw;
5353
}
5454

55-
var setIgnore = message as TestKit.TestActor.SetIgnore;
56-
if(setIgnore != null)
55+
switch (message)
5756
{
58-
_ignore = setIgnore.Ignore;
59-
return true;
60-
}
61-
var watch = message as TestKit.TestActor.Watch;
62-
if(watch != null)
63-
{
64-
Context.Watch(watch.Actor);
65-
return true;
66-
}
67-
var unwatch = message as TestKit.TestActor.Unwatch;
68-
if(unwatch != null)
69-
{
70-
Context.Unwatch(unwatch.Actor);
71-
return true;
72-
}
73-
var setAutoPilot = message as TestKit.TestActor.SetAutoPilot;
74-
if(setAutoPilot != null)
75-
{
76-
_autoPilot = setAutoPilot.AutoPilot;
77-
return true;
78-
}
79-
80-
var spawn = message as TestKit.TestActor.Spawn;
81-
if (spawn != null)
82-
{
83-
var actor = spawn.Apply(Context);
84-
if (spawn._supervisorStrategy.HasValue)
57+
case TestActor.SetIgnore setIgnore:
58+
_ignore = setIgnore.Ignore;
59+
return true;
60+
case TestActor.Watch watch:
61+
Context.Watch(watch.Actor);
62+
return true;
63+
case TestActor.Unwatch unwatch:
64+
Context.Unwatch(unwatch.Actor);
65+
return true;
66+
case TestActor.SetAutoPilot setAutoPilot:
67+
_autoPilot = setAutoPilot.AutoPilot;
68+
return true;
69+
case TestActor.Spawn spawn:
8570
{
86-
_supervisorStrategy.Update(actor, spawn._supervisorStrategy.Value);
71+
var actor = spawn.Apply(Context);
72+
if (spawn._supervisorStrategy.HasValue)
73+
{
74+
_supervisorStrategy.Update(actor, spawn._supervisorStrategy.Value);
75+
}
76+
_queue.Enqueue(new RealMessageEnvelope(actor, Self));
77+
return true;
8778
}
88-
_queue.Enqueue(new RealMessageEnvelope(actor, Self));
89-
return true;
9079
}
9180

9281
var actorRef = Sender;
@@ -100,19 +89,5 @@ protected override bool Receive(object message)
10089
_queue.Enqueue(new RealMessageEnvelope(message, actorRef));
10190
return true;
10291
}
103-
104-
/// <summary>
105-
/// TBD
106-
/// </summary>
107-
protected override void PostStop()
108-
{
109-
var self = Self;
110-
foreach(var messageEnvelope in _queue.ToList())
111-
{
112-
var messageSender = messageEnvelope.Sender;
113-
var message = messageEnvelope.Message;
114-
Context.System.DeadLetters.Tell(new DeadLetter(message, messageSender, self), messageSender);
115-
}
116-
}
11792
}
11893
}

0 commit comments

Comments
 (0)