Skip to content

Commit 8d27f4e

Browse files
quaffsnicoll
authored andcommitted
Include non-default DataSource candidates
This commit updates H2ConsoleAutoConfiguration to consider non-default data sources when logging connection URLs. See gh-44293 Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
1 parent 0eeb0b6 commit 8d27f4e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
* @author Marten Deinum
4848
* @author Stephane Nicoll
4949
* @author Phillip Webb
50+
* @author Yanming Zhou
5051
* @since 1.3.0
5152
*/
5253
@AutoConfiguration(after = DataSourceAutoConfiguration.class)
@@ -113,7 +114,10 @@ private void withThreadContextClassLoader(ClassLoader classLoader, Runnable acti
113114
}
114115

115116
private List<String> getConnectionUrls(ObjectProvider<DataSource> dataSources) {
116-
return dataSources.orderedStream().map(this::getConnectionUrl).filter(Objects::nonNull).toList();
117+
return dataSources.orderedStream(ObjectProvider.UNFILTERED)
118+
.map(this::getConnectionUrl)
119+
.filter(Objects::nonNull)
120+
.toList();
117121
}
118122

119123
private String getConnectionUrl(DataSource dataSource) {

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfigurationTests.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
* @author Stephane Nicoll
5858
* @author Shraddha Yeole
5959
* @author Phillip Webb
60+
* @author Yanming Zhou
6061
*/
6162
class H2ConsoleAutoConfigurationTests {
6263

@@ -206,7 +207,7 @@ DataSource anotherDataSource() throws SQLException {
206207
return mockDataSource("anotherJdbcUrl");
207208
}
208209

209-
@Bean
210+
@Bean(defaultCandidate = false)
210211
@Order(0)
211212
DataSource someDataSource() throws SQLException {
212213
return mockDataSource("someJdbcUrl");

0 commit comments

Comments
 (0)