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

Values in a spring.data.cassandra.config file can't override some defaults defined in CassandraProperties #31238

Closed
wants to merge 3 commits into from

Conversation

ittays
Copy link

@ittays ittays commented Jun 2, 2022

This commit changes two things:

  1. Most primitives on CassandraProperties are replaced with object values.    This allows distinguishing between default-values and no-values. Then   CassandraAutoConfiguration.mapConfig() can use whenNonNull() predicate    to ignore those.

  2. CassandraProperties no longer populate default values that are overridable by spring.data.cassandra.config file. This let the defaults to be applied on top of the file   spring.data.cassandra.config; i.e. the config file have higher    precedence than the defaults, but lower that any spring.data.cassandra.*    property.

On the test side, the file override-defaults.conf is defined to override the values that were non-overridable with values which are different from the default.


In this proposal, the spring.data.cassandra.port configuration has a bit rough behaviour:

  1. In case property spring.data.cassandra.contact-points is configured without a port - the value of spring.data.cassandra.port (which defaults to 9042) is used.

  2. Otherwise, in case contact-points on spring.data.cassandra.config file are defined -- then the contact-points must be configured with a port (as the conf file provides no separate port property).

  3. Otherwise, contact-points defaults to 127.0.0.1:9042 regardless of spring.data.cassandra.port configuration.


Closes gh-31025

Stern, Ittay (is9613) added 3 commits June 1, 2022 17:04
This commit changes two things:

1. Any primitive on CassandraProperties are replaced with object values.
   This allows distinguishing between defaults values and no-values. Then
   CassandraAutoConfiguration.mapConfig() can use whenNonNull() predicate
   to ignore those.

2. CassandraProperties no longer populate default values on any
   property. With that, the defaults can be applied on top of the file
   spring.data.cassandra.config; i.e. the config file have higher
   precedence than the defaults, but lower that any spring.data.cassandra.*
   property.

On the test side, the file `override-defaults.conf` is defined to override
the values that were non-overridable with values which are different from
the default.

Closes spring-projectsgh-31025
port, SSL, schema-action are all not defined in the `spring.data.cassandra.config` file, so we can initialize those on the first configuration layer (default `CassandraProperties` field values).

This simplifies the case of port configuration:

1. In case `spring.data.cassandra.contact-points` is configured without a port - the value of `spring.data.cassandra.port` (which defaults to 9042) is used.

2. Otherwise, in case `contact-points` on spring.data.cassandra.config file are defined -- then it must be configured with a port (no separate port property).

3. Otherwise, `contact-points` defaults to `127.0.0.1:9042` regardless of `spring.data.cassandra.port` configuration.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 2, 2022
@philwebb philwebb added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 9, 2022
@philwebb philwebb added this to the 2.6.x milestone Jun 9, 2022
@philwebb philwebb self-assigned this Jun 22, 2022
@philwebb philwebb changed the title Parameters in spring.data.cassandra.config file will override defaults Values in a spring.data.cassandra.config file cannot override defaults defined in CassandraProperties Jun 23, 2022
@philwebb philwebb changed the title Values in a spring.data.cassandra.config file cannot override defaults defined in CassandraProperties Values in a spring.data.cassandra.config file can't override some defaults defined in CassandraProperties Jun 23, 2022
@philwebb philwebb modified the milestones: 2.6.x, 2.6.9 Jun 23, 2022
philwebb pushed a commit that referenced this pull request Jun 23, 2022
Update `CassandraAutoConfiguration` so that properties in a
`spring.data.cassandra.config` file can override the default values
defined in `CassandraProperties`.

This commit changes two things:

1. Any primitive on `CassandraProperties` are replaced with object values.
   This allows distinguishing between defaults values and no-values. Then
   CassandraAutoConfiguration.mapConfig() can use whenNonNull() predicate
   to ignore those.

2. `CassandraProperties` no longer populate default values on any
   property. With that, the defaults can be applied on top of the file
   spring.data.cassandra.config; i.e. the config file have higher
   precedence than the defaults, but lower that any spring.data.cassandra.*
   property.

See gh-31238
@philwebb philwebb closed this in 9e98f69 Jun 23, 2022
@philwebb
Copy link
Member

Thanks very much for this contribution @ittays, it has now been merged into 2.6.x and forwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CassandraAutoconfiguration leads to ignored parameters in db-config.conf
3 participants