diff --git a/Server/Services/ItemObjectPoolService.cs b/Server/Services/ItemObjectPoolService.cs index 771ad27..6b190e5 100644 --- a/Server/Services/ItemObjectPoolService.cs +++ b/Server/Services/ItemObjectPoolService.cs @@ -10,7 +10,7 @@ namespace Server.Services; public class ItemObjectPoolService : IHostedService { - readonly ConcurrentDictionary _itemObjectPool = new(); + readonly ConcurrentDictionary _itemObjectPool; private readonly ItemReader _itemReader; private readonly ILogger _logger; @@ -19,6 +19,8 @@ public class ItemObjectPoolService : IHostedService _logger = logger; _itemReader = new ItemReader(configuration.GetSection("Game").GetSection("Data").GetValue("Path") ?? string.Empty); + + _itemObjectPool = new ConcurrentDictionary(); } public Task StartAsync(CancellationToken cancellationToken) @@ -30,7 +32,7 @@ public class ItemObjectPoolService : IHostedService var result = _itemObjectPool.TryAdd(itemObject.ItemID, itemObject); if (!result) { - throw new Exception($"Failed to add item {itemObject.ItemID} to the item object pool"); + throw new KeyNotFoundException($"Failed to add item {itemObject.ItemID} to the item object pool"); } _logger.LogTrace("Item with {ID} has been added", itemObject.ItemID); @@ -43,7 +45,6 @@ public class ItemObjectPoolService : IHostedService public Task StopAsync(CancellationToken cancellationToken) { - return Task.CompletedTask; }