diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java index f61328bf3c..897342e12f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java @@ -16,6 +16,7 @@ package org.springframework.boot.autoconfigure.flyway; +import java.sql.DatabaseMetaData; import java.util.Collection; import java.util.Collections; import java.util.HashSet; @@ -408,7 +409,7 @@ public class FlywayAutoConfiguration { private DatabaseDriver getDatabaseDriver() { try { - String url = JdbcUtils.extractDatabaseMetaData(this.dataSource, "getURL"); + String url = JdbcUtils.extractDatabaseMetaData(this.dataSource, DatabaseMetaData::getURL); return DatabaseDriver.fromJdbcUrl(url); } catch (MetaDataAccessException ex) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/SqlDialectLookup.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/SqlDialectLookup.java index 5c03f0bde9..d3c81f88fe 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/SqlDialectLookup.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/SqlDialectLookup.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ package org.springframework.boot.autoconfigure.jooq; +import java.sql.DatabaseMetaData; + import javax.sql.DataSource; import org.apache.commons.logging.Log; @@ -49,7 +51,7 @@ final class SqlDialectLookup { return SQLDialect.DEFAULT; } try { - String url = JdbcUtils.extractDatabaseMetaData(dataSource, "getURL"); + String url = JdbcUtils.extractDatabaseMetaData(dataSource, DatabaseMetaData::getURL); SQLDialect sqlDialect = JDBCUtils.dialect(url); if (sqlDialect != null) { return sqlDialect; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DatabaseLookup.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DatabaseLookup.java index 6cc0743eea..4efbafe263 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DatabaseLookup.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DatabaseLookup.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.springframework.boot.autoconfigure.orm.jpa; +import java.sql.DatabaseMetaData; import java.util.Collections; import java.util.EnumMap; import java.util.Map; @@ -70,7 +71,7 @@ final class DatabaseLookup { return Database.DEFAULT; } try { - String url = JdbcUtils.extractDatabaseMetaData(dataSource, "getURL"); + String url = JdbcUtils.extractDatabaseMetaData(dataSource, DatabaseMetaData::getURL); DatabaseDriver driver = DatabaseDriver.fromJdbcUrl(url); Database database = LOOKUP.get(driver); if (database != null) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java index c8f22ce1af..65a4ecad6b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java @@ -407,8 +407,8 @@ class WebFluxAutoConfigurationTests { assertThat(handlerMap).hasSize(2); for (Object handler : handlerMap.values()) { if (handler instanceof ResourceWebHandler) { - assertThat(((ResourceWebHandler) handler).getCacheControl()) - .isEqualToComparingFieldByField(CacheControl.maxAge(5, TimeUnit.SECONDS)); + assertThat(((ResourceWebHandler) handler).getCacheControl()).usingRecursiveComparison() + .isEqualTo(CacheControl.maxAge(5, TimeUnit.SECONDS)); } } }); @@ -424,8 +424,8 @@ class WebFluxAutoConfigurationTests { assertThat(handlerMap).hasSize(2); for (Object handler : handlerMap.values()) { if (handler instanceof ResourceWebHandler) { - assertThat(((ResourceWebHandler) handler).getCacheControl()).isEqualToComparingFieldByField( - CacheControl.maxAge(5, TimeUnit.SECONDS).proxyRevalidate()); + assertThat(((ResourceWebHandler) handler).getCacheControl()).usingRecursiveComparison() + .isEqualTo(CacheControl.maxAge(5, TimeUnit.SECONDS).proxyRevalidate()); } } }); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java index fa03544f5e..87ed0718f1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java @@ -918,8 +918,8 @@ class WebMvcAutoConfigurationTests { for (Object handler : handlerMap.keySet()) { if (handler instanceof ResourceHttpRequestHandler) { assertThat(((ResourceHttpRequestHandler) handler).getCacheSeconds()).isEqualTo(-1); - assertThat(((ResourceHttpRequestHandler) handler).getCacheControl()) - .isEqualToComparingFieldByField(CacheControl.maxAge(5, TimeUnit.SECONDS).proxyRevalidate()); + assertThat(((ResourceHttpRequestHandler) handler).getCacheControl()).usingRecursiveComparison() + .isEqualTo(CacheControl.maxAge(5, TimeUnit.SECONDS).proxyRevalidate()); } } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/AbstractDataSourceInitializer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/AbstractDataSourceInitializer.java index 9696260a97..07195ff874 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/AbstractDataSourceInitializer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/AbstractDataSourceInitializer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ package org.springframework.boot.jdbc; +import java.sql.DatabaseMetaData; + import javax.annotation.PostConstruct; import javax.sql.DataSource; @@ -87,7 +89,7 @@ public abstract class AbstractDataSourceInitializer { protected String getDatabaseName() { try { String productName = JdbcUtils.commonDatabaseName( - JdbcUtils.extractDatabaseMetaData(this.dataSource, "getDatabaseProductName").toString()); + JdbcUtils.extractDatabaseMetaData(this.dataSource, DatabaseMetaData::getDatabaseProductName)); DatabaseDriver databaseDriver = DatabaseDriver.fromProductName(productName); if (databaseDriver == DatabaseDriver.UNKNOWN) { throw new IllegalStateException("Unable to detect database type");