Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hangfire 1.6.0 beta2 is not allowing for adding JobFilterAttributes #563

Closed
abdelrady opened this issue May 4, 2016 · 4 comments
Closed
Labels

Comments

@abdelrady
Copy link

Hi,

We are using Hangfire 1.6.0 beta2 for a new feature created by this 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.

startup.cs.txt

@ChrisTowles
Copy link

ChrisTowles commented May 5, 2016

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 });

@odinserj odinserj added the t: bug label May 6, 2016
@odinserj odinserj added this to the 1.6.0 milestone May 6, 2016
@odinserj
Copy link
Member

odinserj commented May 6, 2016

Guys, thanks for reporting and investigating this ❤️ 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.

@odinserj odinserj closed this as completed May 6, 2016
@abdelrady
Copy link
Author

Thanks @odinserj for the quick fix, do you have any plans to release this to NuGet packages soon ?

@odinserj
Copy link
Member

odinserj commented May 6, 2016

I'm planning to release it with beta3, next week or so. Currently you can use the CI feed to obtain the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants