diff --git a/src/Proto.Actor/Extensions/ActorSystemExtensions.cs b/src/Proto.Actor/Extensions/ActorSystemExtensions.cs
index a9bd4f5b06..1254be6a25 100644
--- a/src/Proto.Actor/Extensions/ActorSystemExtensions.cs
+++ b/src/Proto.Actor/Extensions/ActorSystemExtensions.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------
+// -----------------------------------------------------------------------
//
// Copyright (C) 2015-2022 Asynkron AB All rights reserved
//
@@ -19,13 +19,17 @@ public class ActorSystemExtensions
public T? Get() where T : IActorSystemExtension
{
var id = IActorSystemExtension.Id;
- return (T) _extensions[id];
+ if (id < _extensions.Length)
+ return (T) _extensions[id];
+ return default;
}
public T GetRequired(string? notFoundMessage=null) where T : IActorSystemExtension
{
var id = IActorSystemExtension.Id;
- var res = (T) _extensions[id];
+ T? res = default;
+ if (id < _extensions.Length)
+ res = (T) _extensions[id];
if (res is null)
{