Skip to content

Commit c734663

Browse files
committed
Merge pull request #39948 from christophstrobl
* gh-39948: Polish "Delay interaction with Lazy CqlSession bean until first usage" Delay interaction with Lazy CqlSession bean until first usage Closes gh-39948
2 parents 3ac7ead + 21bd300 commit c734663

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@
3232
import org.springframework.boot.autoconfigure.domain.EntityScanPackages;
3333
import org.springframework.boot.context.properties.bind.Binder;
3434
import org.springframework.context.annotation.Bean;
35+
import org.springframework.context.annotation.Lazy;
3536
import org.springframework.core.env.Environment;
3637
import org.springframework.data.cassandra.CassandraManagedTypes;
3738
import org.springframework.data.cassandra.SessionFactory;
@@ -54,6 +55,7 @@
5455
* @author Eddú Meléndez
5556
* @author Mark Paluch
5657
* @author Madhura Bhave
58+
* @author Christoph Strobl
5759
* @since 1.3.0
5860
*/
5961
@AutoConfiguration(after = CassandraAutoConfiguration.class)
@@ -63,7 +65,7 @@ public class CassandraDataAutoConfiguration {
6365

6466
private final CqlSession session;
6567

66-
public CassandraDataAutoConfiguration(CqlSession session) {
68+
public CassandraDataAutoConfiguration(@Lazy CqlSession session) {
6769
this.session = session;
6870
}
6971

@@ -95,7 +97,7 @@ public CassandraMappingContext cassandraMappingContext(CassandraManagedTypes cas
9597
public CassandraConverter cassandraConverter(CassandraMappingContext mapping,
9698
CassandraCustomConversions conversions) {
9799
MappingCassandraConverter converter = new MappingCassandraConverter(mapping);
98-
converter.setCodecRegistry(this.session.getContext().getCodecRegistry());
100+
converter.setCodecRegistry(() -> this.session.getContext().getCodecRegistry());
99101
converter.setCustomConversions(conversions);
100102
converter.setUserTypeResolver(new SimpleUserTypeResolver(this.session));
101103
return converter;

0 commit comments

Comments
 (0)