Hi,
We are using Hangfire 1.6.0 beta2 for a new feature created by this pull
https://github.com/HangfireIO/Hangfire/pull/523
but we faced an issue adding a JobFilterAttribute to GlobalJobFilters.Filters when executing any job, it will fire null reference exception.
After some investigation in latest source code in dev branch we realized that the root cause of this issue is this line in GlobalJobFilters.cs
static GlobalJobFilters()
{
Filters = new JobFilterCollection
{
new CaptureCultureAttribute(),
new AutomaticRetryAttribute(),
new StatisticsHistoryAttribute(),
new ContinuationsSupportAttribute()
};
}
It seems that the collection initializer is setting JobFilterProviders.Providers -> first element in list = null
By reverting this initialization to old way, issue fixed
static GlobalJobFilters()
{
Filters = new JobFilterCollection();
Filters.Add(new CaptureCultureAttribute());
Filters.Add(new AutomaticRetryAttribute());
Filters.Add(new StatisticsHistoryAttribute());
Filters.Add(new ContinuationsSupportAttribute());
}
We rolled back to beta1 which doesn't have this issue till you have the chance to fix it.
Attached same MVC sample (startup.cs file) in dev branch with adding a simple JobFilterAttribute to show you the issue.
Just confirming I ran into this same issue with GlobalJobFilters.Filters on 1.6.0 beta2 when using the following. Thanks @abdelrady for tracking down the change. Was caused by using the following.
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = 3 });
Guys, thanks for reporting and investigating this :heart: It is awesome when a bug is reported during the beta. The fix is available in the CI Feed in version 1.6.0-build-02018.
Thanks @odinserj for the quick fix, do you have any plans to release this to NuGet packages soon ?
I'm planning to release it with beta3, next week or so. Currently you can use the CI feed to obtain the fix