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

Unknown configuration property 'quartz.config' #2212

Closed
delta-emil opened this issue Dec 5, 2023 · 1 comment
Closed

Unknown configuration property 'quartz.config' #2212

delta-emil opened this issue Dec 5, 2023 · 1 comment
Milestone

Comments

@delta-emil
Copy link
Contributor

delta-emil commented Dec 5, 2023

Describe the bug

If you let the StdSchedulerFactory load the configuration from a file specified the environment variable "quartz.config" (defined in StdSchedulerFactory.PropertiesFile), then you get a Quartz.SchedulerConfigException saying Unknown configuration property 'quartz.config'

Version used

Appeared in v3.8.0, was not present in v.3.7.0

Seems to have been caused by 5562a9a

That change introduced an explicit allowed list of configuration values, which doesn't include "quartz.config", but "quartz.config" is always added from the environment variables by OverrideWithSysProps.

To Reproduce

    [Test]
    public async Task TestFactoryShouldLoadPropertiesFromFileWhosePathIsGivenByEnvVariable()
    {
        var tempFile = Path.GetTempFileName();
        try
        {
            const string InstanceName = "TestInstance";

            File.WriteAllText(tempFile, $"{StdSchedulerFactory.PropertySchedulerInstanceName}={InstanceName}");

            Environment.SetEnvironmentVariable(StdSchedulerFactory.PropertiesFile, tempFile);

            var factory = new StdSchedulerFactory();
            factory.Initialize(); // <- optional, because `GetScheduler` does it anyway
            var scheduler = await factory.GetScheduler();

            Assert.AreEqual(InstanceName, scheduler.SchedulerName);
        }
        finally
        {
            try
            {
                File.Delete(tempFile);
            }
            catch (Exception)
            {
                // ignore temp file delete error
            }

            Environment.SetEnvironmentVariable(StdSchedulerFactory.PropertiesFile, null);
        }
    }

Expected behavior

Using environment variable "quartz.config" to specify the path to the config file should not cause an exception.

Perhaps OverrideWithSysProps should explicitly skip environment variable "quartz.config" (StdSchedulerFactory.PropertiesFile)?

@lahma lahma added this to the vNext milestone Dec 5, 2023
@lahma
Copy link
Member

lahma commented Dec 5, 2023

Thanks for the detailed bug report and test case. Skipping this in override seems reasonable. Would you like to take a stab creating a fix via a PR against the 3.x branch?

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

No branches or pull requests

2 participants