aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Monteiro <marknr.monteiro@protonmail.com>2020-03-21 23:19:24 +0100
committerMark Monteiro <marknr.monteiro@protonmail.com>2020-03-21 23:19:24 +0100
commitdc2b8c464672d7bb69a32cf6f95555872f1f7ddf (patch)
tree6083bd3d426652797ad735a117258ec9fcb551ee
parent72c822513f746fd30575a6dc2b076d647ffec4f3 (diff)
Log a warning if an attempt is made to register an invalid service type
-rw-r--r--Emby.Server.Implementations/Services/ServiceController.cs15
1 files changed, 15 insertions, 0 deletions
diff --git a/Emby.Server.Implementations/Services/ServiceController.cs b/Emby.Server.Implementations/Services/ServiceController.cs
index d963f9043..3f9c8778b 100644
--- a/Emby.Server.Implementations/Services/ServiceController.cs
+++ b/Emby.Server.Implementations/Services/ServiceController.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using Emby.Server.Implementations.HttpServer;
using MediaBrowser.Model.Services;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.Services
{
@@ -11,6 +12,13 @@ namespace Emby.Server.Implementations.Services
public class ServiceController
{
+ private readonly ILogger _log;
+
+ public ServiceController(ILogger<ServiceController> log)
+ {
+ _log = log;
+ }
+
public void Init(HttpListenerHost appHost, IEnumerable<Type> serviceTypes)
{
foreach (var serviceType in serviceTypes)
@@ -21,6 +29,13 @@ namespace Emby.Server.Implementations.Services
public void RegisterService(HttpListenerHost appHost, Type serviceType)
{
+ // Make sure the provided type implements IService
+ if (!serviceType.IsAssignableFrom(typeof(IService)))
+ {
+ _log.LogWarning("Tried to register a service that does not implement IService: {ServiceType}", serviceType);
+ return;
+ }
+
var processedReqs = new HashSet<Type>();
var actions = ServiceExecGeneral.Reset(serviceType);