Skip to content

Conversation

christophstrobl
Copy link
Member

@christophstrobl christophstrobl commented Mar 15, 2024

Though the CqlSession provided by the CassandraAutoConfiguration can be lazy, the configuration for data-cassandra triggers early bean instantiation.
This PR uses changed API in the data-cassandra project to make use of the intended lazy bean initialization and therefore prevents the application from failing already at startup when cassandra might not (yet) be ready.

Requires: Upgrade to spring-data:2024.0.0-RC1
Depends on: spring-projects/spring-data-cassandra#1485

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 15, 2024
Though the CqlSession provided by the CassandraAutoConfiguration can be lazy the configuration for data cassandra triggers early bean instantiation.
This commit uses changed API in the data-cassandra project to make use of the intended lazy bean initialization and therefore prevents the application from failing already at startup when cassandra might not (yet) be ready.
@christophstrobl christophstrobl force-pushed the data/cassandra/lazy-cql-session-init branch from 9ffc776 to ec29263 Compare March 18, 2024 15:20
@@ -63,7 +65,7 @@ public class CassandraDataAutoConfiguration {

private final CqlSession session;

public CassandraDataAutoConfiguration(CqlSession session) {
public CassandraDataAutoConfiguration(@Lazy CqlSession session) {
Copy link
Member

@wilkinsona wilkinsona Mar 18, 2024

Choose a reason for hiding this comment

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

I wonder if we should inject and store an ObjectProvider<CqlSession> here rather than relying on the proxying that @Lazy requires.

Edit: Looking more closely, I'm not sure how that would play with the user type resolver below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Relying on the proxy was the less invasive variant.

@wilkinsona wilkinsona added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 20, 2024
@wilkinsona wilkinsona added this to the 3.3.x milestone Mar 20, 2024
@wilkinsona wilkinsona added the status: on-hold We can't start working on this issue yet label Mar 20, 2024
@wilkinsona wilkinsona removed the status: on-hold We can't start working on this issue yet label Apr 10, 2024
@wilkinsona wilkinsona changed the title Delay interaction with Lazy CqlSession bean until first required usage. Delay interaction with Lazy CqlSession bean until first required usage Apr 10, 2024
@wilkinsona wilkinsona modified the milestones: 3.3.x, 3.3.0-RC1 Apr 10, 2024
wilkinsona pushed a commit that referenced this pull request Apr 10, 2024
Though the CqlSession provided by the CassandraAutoConfiguration can
be lazy, the configuration for Data Cassandra triggers early bean
instantiation. This commit uses new APIs in Data Cassandra to make
use of the intended lazy bean initialization and therefore prevents
the application from failing to start up when Cassandra might not yet
be ready.

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

Successfully merging this pull request may close these issues.

3 participants