Skip to content

Fix JSON schedule config not loaded for named schedulers using root Quartz section (#3106)#3113

Merged
lahma merged 1 commit into
3.xfrom
3106
Jun 17, 2026
Merged

Fix JSON schedule config not loaded for named schedulers using root Quartz section (#3106)#3113
lahma merged 1 commit into
3.xfrom
3106

Conversation

@lahma

@lahma lahma commented Jun 17, 2026

Copy link
Copy Markdown
Member

Problem

Fixes #3106.

When configuring named schedulers under Quartz:Schedulers:{name} and calling the named AddQuartz overload with the root Quartz section, nothing is registered (0 jobs, 0 triggers):

// FAILS today — registers 0 jobs, 0 triggers
services.AddQuartz("LocalScheduler", Configuration.GetSection("Quartz"), _ => { });

// Worked only with the scheduler-specific section
services.AddQuartz("LocalScheduler", Configuration.GetSection("Quartz:Schedulers:LocalScheduler"), _ => { });

The named overload assumed the section it received was the scheduler's own section, so it read flat properties and the Schedule/Scheduling sub-sections directly under it. With the root section those live under Schedulers:{name}:..., so they were never found (properties were lost too, since Schedulers is a reserved/skipped key).

Fix

  • Named overload auto-resolves the sub-section: AddQuartz(name, configuration) now resolves a Schedulers:{name} child when present and uses it for both property conversion and JsonSchedulingHelper; otherwise it uses the section as-is. Fully backward-compatible — the recursive call from the root overload and the existing flat-section usage are unaffected.
  • Clear error for an ambiguous mix: the root AddQuartz(IConfiguration) overload now throws a SchedulerConfigException when a top-level Schedule/Scheduling section is combined with a Schedulers sub-section. Previously that top-level scheduling data was silently dropped (it has no scheduler to attach to once named schedulers are in play).

Tests & docs

  • New AddQuartz_NamedScheduler_WithRootSectionContainingSchedulers_ResolvesSubsection (reproduction).
  • New AddQuartz_SchedulersWithTopLevelSchedule_Throws (guard).
  • Documented both behaviors in the JSON configuration docs.

All JsonSchedulingTests pass.

🤖 Generated with Claude Code

…uartz section (#3106)

The named AddQuartz(name, configuration) overload assumed the passed section
was the scheduler's own section, reading flat properties and Schedule/Scheduling
directly under it. When given the root Quartz section (with the schedule under
Schedulers:{name}), nothing was registered.

- The named overload now resolves the Schedulers:{name} sub-section when present,
  using it for both property conversion and JsonSchedulingHelper; otherwise it
  uses the section as-is (fully backward compatible).
- The root AddQuartz(IConfiguration) overload now throws a clear
  SchedulerConfigException when a top-level Schedule/Scheduling section is combined
  with a Schedulers sub-section (previously silently dropped).

Adds regression tests and documents the behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

@lahma
lahma merged commit d6a454f into 3.x Jun 17, 2026
16 checks passed
@lahma
lahma deleted the 3106 branch June 17, 2026 07:10
This was referenced Jun 27, 2026
This was referenced Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant