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

Don't attempt to configure a job if the expression is null. #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

randellhodges
Copy link

If you use the AutoConfigure extension method:

        public void ConfigureServices(IServiceCollection services)
        {
             ...
            services.InitializeCronServices();
            services.AutoConfigurer();
        }

And decide you want to "disable a job and comment out the configuration:

  //"CronJobs": {
  //  "CronJob1": {
  //    "CronExpression": "*/1 * * * *"
  //  }

Currently you'll get an exception with the call to AutoConfigurer:

In your job, the constructor will throw:

        public CronJob1(ILogger<CronJob1> logger, ICronConfiguration<CronJob1> cronConfiguration) : base(cronConfiguration.CronExpression, cronConfiguration.TimeZoneInfo, cronConfiguration.CronFormat)
        {
            ...
        }

The base(cronConfiguration.CronExpression will throw because it tries to pass null into Chronos.

This change will ignore and not create an instance of the job class if the expression is not defined.

… you comment out the configuration in the appsettings.json file.
@furkandeveloper furkandeveloper self-requested a review June 8, 2022 16:29
@furkandeveloper furkandeveloper self-assigned this Jun 8, 2022
@furkandeveloper furkandeveloper added bug Something isn't working enhancement New feature or request priority:medium priority:low labels Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request priority:low priority:medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants