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

Dont use SchedulerFactory reserved prefixes #116

Conversation

aegbert5
Copy link
Contributor

@aegbert5 aegbert5 commented Oct 7, 2024

When using the newest version of piezo-admin with the StdSchedulerFactory provided by quartz, the following exceptions are thrown:

Exception in thread "main" org.quartz.SchedulerException: Could not initialize DataSource: {dataSourceName} [See nested exception: java.lang.NoSuchMethodException: No setter for property 'ipFailover']
    at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:1054)
    at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1579)
    ...
Caused by: java.lang.NoSuchMethodException: No setter for property 'ipFailover'
    at org.quartz.impl.StdSchedulerFactory.setBeanProps(StdSchedulerFactory.java:1467)
    at org.quartz.impl.StdSchedulerFactory.populateProviderWithExtraProps(StdSchedulerFactory.java:1425)
    at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:1052)

It seems that the StdSchedulerFactory in quartz is very protective of the configuration properties provided for org.quartz.jobStore.dataSource={dataSourceName}. The properties set on org.quartz.dataSource.{dataSourceName} must follow the provided pattern and org.quartz.dataSource.{dataSourceName}.ipFailover is not in that list by default:

org.quartz.dataSource.{dataSourceName}.driver
org.quartz.dataSource.{dataSourceName}.URL
org.quartz.dataSource.{dataSourceName}.user
org.quartz.dataSource.{dataSourceName}.password
org.quartz.dataSource.{dataSourceName}.maxConnections
org.quartz.dataSource.{dataSourceName}.validationQuery
org.quartz.dataSource.{dataSourceName}.poolingProvider

I think the best option is to use a different prefix for ipFailover that isn't already reserved by StdSchedulerFactory.scala

@aegbert5 aegbert5 force-pushed the dont-use-reserved-prefixes-for-supporting-ip-failover branch from 0bf0ae7 to 0af292f Compare October 7, 2024 17:37
@tmccombs tmccombs merged commit 50d4fad into lucidsoftware:master Oct 7, 2024
1 check passed
@@ -21,7 +21,7 @@ class ConnectionProvider(props: Properties) {
val logger = LoggerFactory.getLogger(this.getClass)
private val dataSource = props.getProperty("org.quartz.jobStore.dataSource")
private val jdbcURL = if (dataSource != null) props.getProperty("org.quartz.dataSource." + dataSource + ".URL") else null
private val detectIpAddressFailover = if (dataSource != null) props.getProperty("org.quartz.dataSource." + dataSource + ".ipFailover") == "true" else false
private val detectIpAddressFailover = props.getProperty("supportIPFailover") == "true"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume getProperty handles null values properly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, props.getProperty("supportIPFailover") will return null if the value is not in the config. And null == "true" will return false

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.

3 participants