diff --git a/LICENSE.md b/LICENSE.md
index 7afb1a4af..6e6e3d749 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,7 +1,7 @@
License
========
-Copyright © 2022 Hangfire OÜ.
+Copyright © 2023 Hangfire OÜ.
Hangfire software is an open-source software that is multi-licensed under the terms of the licenses listed in this file. Recipients may choose the terms under which they are want to use or distribute the software, when all the preconditions of a chosen license are satisfied.
diff --git a/README.md b/README.md
index 3016535c3..ec8849396 100644
--- a/README.md
+++ b/README.md
@@ -167,7 +167,7 @@ In order to give the community time to respond and upgrade we strongly urge you
License
--------
-Copyright © 2022 Hangfire OÜ.
+Copyright © 2023 Hangfire OÜ.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/nuspecs/Hangfire.Core.nuspec b/nuspecs/Hangfire.Core.nuspec
index d4fbabe61..a7ac5633a 100644
--- a/nuspecs/Hangfire.Core.nuspec
+++ b/nuspecs/Hangfire.Core.nuspec
@@ -16,7 +16,7 @@ An easy and reliable way to perform fire-and-forget, delayed and recurring, long
Backed by Redis, SQL Server, SQL Azure or MSMQ. This is a .NET alternative to Sidekiq, Resque and Celery.
https://www.hangfire.io/
- Copyright © 2013-2022 Hangfire OÜ
+ Copyright © 2013-2023 Hangfire OÜ
Hangfire OWIN Long-Running Background Fire-And-Forget Delayed Recurring Tasks Jobs Scheduler Threading Queues
https://www.hangfire.io/blog/
diff --git a/nuspecs/Hangfire.NetCore.nuspec b/nuspecs/Hangfire.NetCore.nuspec
index 8fd663ac6..da399b333 100644
--- a/nuspecs/Hangfire.NetCore.nuspec
+++ b/nuspecs/Hangfire.NetCore.nuspec
@@ -11,7 +11,7 @@
false
https://raw.github.com/HangfireIO/Hangfire/master/LICENSE.md
.NET Core's Worker Service host support for Hangfire (background job system for ASP.NET applications).
- Copyright © 2019-2022 Hangfire OÜ
+ Copyright © 2019-2023 Hangfire OÜ
hangfire netcore
https://www.hangfire.io/blog/
diff --git a/nuspecs/Hangfire.SqlServer.MSMQ.nuspec b/nuspecs/Hangfire.SqlServer.MSMQ.nuspec
index f1d27f763..9037de09a 100644
--- a/nuspecs/Hangfire.SqlServer.MSMQ.nuspec
+++ b/nuspecs/Hangfire.SqlServer.MSMQ.nuspec
@@ -11,7 +11,7 @@
false
https://raw.github.com/HangfireIO/Hangfire/master/LICENSE.md
MSMQ queues support for SQL Server job storage implementation for Hangfire (background job system for ASP.NET applications).
- Copyright © 2014-2022 Hangfire OÜ
+ Copyright © 2014-2023 Hangfire OÜ
Hangfire SqlServer MSMQ
https://www.hangfire.io/blog/
diff --git a/src/Hangfire.Core/Common/CancellationTokenExtentions.cs b/src/Hangfire.Core/Common/CancellationTokenExtentions.cs
index 2e8adbeaf..4d6c9bfed 100644
--- a/src/Hangfire.Core/Common/CancellationTokenExtentions.cs
+++ b/src/Hangfire.Core/Common/CancellationTokenExtentions.cs
@@ -22,8 +22,6 @@ namespace Hangfire.Common
{
public static class CancellationTokenExtentions
{
- private static readonly ILog Logger = LogProvider.GetLogger(typeof(CancellationTokenExtentions));
-
///
/// Returns a class that contains a that is set, when
/// the given is canceled. This method is based
@@ -72,8 +70,15 @@ public static bool Wait(this CancellationToken cancellationToken, TimeSpan timeo
timeout >= timeoutThreshold &&
stopwatch.Elapsed < elapsedThreshold)
{
- Logger.Error($"Actual wait time for non-canceled token was '{stopwatch.Elapsed}' instead of '{timeout}', wait result: {waitResult}, using protective wait. Please report this to Hangfire developers.");
- Thread.Sleep(protectionTime);
+ try
+ {
+ var logger = LogProvider.GetLogger(typeof(CancellationTokenExtentions));
+ logger.Error($"Actual wait time for non-canceled token was '{stopwatch.Elapsed}' instead of '{timeout}', wait result: {waitResult}, using protective wait. Please report this to Hangfire developers.");
+ }
+ finally
+ {
+ Thread.Sleep(protectionTime);
+ }
}
return waitResult;
diff --git a/src/Hangfire.Core/Processing/TaskExtensions.cs b/src/Hangfire.Core/Processing/TaskExtensions.cs
index bc4b8a939..181f116eb 100644
--- a/src/Hangfire.Core/Processing/TaskExtensions.cs
+++ b/src/Hangfire.Core/Processing/TaskExtensions.cs
@@ -26,7 +26,6 @@ namespace Hangfire.Processing
{
internal static class TaskExtensions
{
- private static readonly ILog Logger = LogProvider.GetLogger(typeof(TaskExtensions));
private static readonly Type[] EmptyTypes = new Type[0];
private static readonly WaitHandle InvalidWaitHandleInstance = new InvalidWaitHandle();
@@ -58,8 +57,15 @@ public static bool WaitOne([NotNull] this WaitHandle waitHandle, TimeSpan timeou
timeout >= timeoutThreshold &&
stopwatch.Elapsed < elapsedThreshold)
{
- Logger.Error($"Actual wait time for non-canceled token was '{stopwatch.Elapsed}' instead of '{timeout}', wait result: {waitResult}, using protective wait. Please report this to Hangfire developers.");
- Thread.Sleep(protectionTime);
+ try
+ {
+ var logger = LogProvider.GetLogger(typeof(TaskExtensions));
+ logger.Error($"Actual wait time for non-canceled token was '{stopwatch.Elapsed}' instead of '{timeout}', wait result: {waitResult}, using protective wait. Please report this to Hangfire developers.");
+ }
+ finally
+ {
+ Thread.Sleep(protectionTime);
+ }
}
token.ThrowIfCancellationRequested();
diff --git a/src/Hangfire.Core/Server/AspNetShutdownDetector.cs b/src/Hangfire.Core/Server/AspNetShutdownDetector.cs
index c61bf20a9..657ad9a29 100644
--- a/src/Hangfire.Core/Server/AspNetShutdownDetector.cs
+++ b/src/Hangfire.Core/Server/AspNetShutdownDetector.cs
@@ -23,7 +23,6 @@ namespace Hangfire.Server
{
internal static class AspNetShutdownDetector
{
- private static readonly ILog Logger = LogProvider.GetLogger(typeof(AspNetShutdownDetector));
private static readonly TimeSpan CheckForShutdownTimerInterval = TimeSpan.FromMilliseconds(250);
private static readonly CancellationTokenSource CancellationTokenSource = new CancellationTokenSource();
@@ -121,7 +120,7 @@ private static void EnsureInitialized()
}
catch (Exception ex) when (ex.IsCatchableExceptionType())
{
- Logger.ErrorException("Failed to initialize shutdown triggers for ASP.NET application.", ex);
+ GetLogger().ErrorException("Failed to initialize shutdown triggers for ASP.NET application.", ex);
}
}
@@ -155,7 +154,7 @@ private static void CheckForAppDomainShutdown(object state)
}
catch (Exception ex) when (ex.IsCatchableExceptionType())
{
- Logger.ErrorException(
+ GetLogger().ErrorException(
"An exception occurred while checking for ASP.NET shutdown, will not able to do the checks properly.",
ex);
}
@@ -163,7 +162,7 @@ private static void CheckForAppDomainShutdown(object state)
private static void Cancel(string reason)
{
- Logger.Info($"ASP.NET application is shutting down: {reason}.");
+ GetLogger().Info($"ASP.NET application is shutting down: {reason}.");
try
{
@@ -174,7 +173,7 @@ private static void Cancel(string reason)
}
catch (AggregateException ag)
{
- Logger.ErrorException("One or more exceptions were thrown during app pool shutdown: ", ag);
+ GetLogger().ErrorException("One or more exceptions were thrown during app pool shutdown: ", ag);
}
}
@@ -189,12 +188,12 @@ private static void RegisterForStopListeningEvent(ref bool success)
if (stopEvent == null) return;
stopEvent.AddEventHandler(null, new EventHandler(StopListening));
- Logger.Debug("HostingEnvironment.StopListening shutdown trigger initialized successfully.");
+ GetLogger().Debug("HostingEnvironment.StopListening shutdown trigger initialized successfully.");
success = true;
}
catch (Exception ex) when (ex.IsCatchableExceptionType())
{
- Logger.DebugException("Unable to initialize HostingEnvironment.StopListening shutdown trigger", ex);
+ GetLogger().DebugException("Unable to initialize HostingEnvironment.StopListening shutdown trigger", ex);
}
}
@@ -215,7 +214,7 @@ private static void InitializeShutdownReason(ref bool success)
_shutdownReasonFunc = ShutdownReasonFunc;
- Logger.Debug("HostingEnvironment.ShutdownReason shutdown trigger initialized successfully.");
+ GetLogger().Debug("HostingEnvironment.ShutdownReason shutdown trigger initialized successfully.");
success = true;
string ShutdownReasonFunc()
@@ -231,7 +230,7 @@ string ShutdownReasonFunc()
}
catch (Exception ex) when (ex.IsCatchableExceptionType())
{
- Logger.TraceException("Unable to call the HostingEnvironment.ShutdownReason property due to an exception.", ex);
+ GetLogger().TraceException("Unable to call the HostingEnvironment.ShutdownReason property due to an exception.", ex);
}
return null;
@@ -239,7 +238,7 @@ string ShutdownReasonFunc()
}
catch (Exception ex) when (ex.IsCatchableExceptionType())
{
- Logger.DebugException("Unable to initialize HostingEnvironment.ShutdownReason shutdown trigger", ex);
+ GetLogger().DebugException("Unable to initialize HostingEnvironment.ShutdownReason shutdown trigger", ex);
}
}
@@ -255,12 +254,12 @@ private static void InitializeMgdHasConfigChanged(ref bool success)
_checkConfigChangedFunc = (Func)Delegate.CreateDelegate(typeof(Func), methodInfo);
- Logger.Debug("UnsafeIISMethods.MgdHasConfigChanged shutdown trigger initialized successfully.");
+ GetLogger().Debug("UnsafeIISMethods.MgdHasConfigChanged shutdown trigger initialized successfully.");
success = true;
}
catch (Exception ex) when (ex.IsCatchableExceptionType())
{
- Logger.DebugException("Unable to initialize UnsafeIISMethods.MgdHasConfigChanged shutdown trigger", ex);
+ GetLogger().DebugException("Unable to initialize UnsafeIISMethods.MgdHasConfigChanged shutdown trigger", ex);
}
}
@@ -282,12 +281,12 @@ private static void InitializeDisposingHttpRuntime(ref bool success)
_disposingHttpRuntime = () => disposingHttpRuntime(theRuntime());
- Logger.Debug("HttpRuntime._disposingHttpRuntime shutdown trigger initialized successfully.");
+ GetLogger().Debug("HttpRuntime._disposingHttpRuntime shutdown trigger initialized successfully.");
success = true;
}
catch (Exception ex)
{
- Logger.DebugException("Unable to initialize HttpRuntime._disposingHttpRuntime shutdown trigger", ex);
+ GetLogger().DebugException("Unable to initialize HttpRuntime._disposingHttpRuntime shutdown trigger", ex);
}
}
@@ -305,5 +304,10 @@ private static Func