Fix use of deprecated methods

pull/23215/head
Stephane Nicoll 4 years ago
parent f24d6bf273
commit 73c039e4b8

@ -16,6 +16,7 @@
package org.springframework.boot.autoconfigure.flyway; package org.springframework.boot.autoconfigure.flyway;
import java.sql.DatabaseMetaData;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
@ -408,7 +409,7 @@ public class FlywayAutoConfiguration {
private DatabaseDriver getDatabaseDriver() { private DatabaseDriver getDatabaseDriver() {
try { try {
String url = JdbcUtils.extractDatabaseMetaData(this.dataSource, "getURL"); String url = JdbcUtils.extractDatabaseMetaData(this.dataSource, DatabaseMetaData::getURL);
return DatabaseDriver.fromJdbcUrl(url); return DatabaseDriver.fromJdbcUrl(url);
} }
catch (MetaDataAccessException ex) { catch (MetaDataAccessException ex) {

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.jooq; package org.springframework.boot.autoconfigure.jooq;
import java.sql.DatabaseMetaData;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -49,7 +51,7 @@ final class SqlDialectLookup {
return SQLDialect.DEFAULT; return SQLDialect.DEFAULT;
} }
try { try {
String url = JdbcUtils.extractDatabaseMetaData(dataSource, "getURL"); String url = JdbcUtils.extractDatabaseMetaData(dataSource, DatabaseMetaData::getURL);
SQLDialect sqlDialect = JDBCUtils.dialect(url); SQLDialect sqlDialect = JDBCUtils.dialect(url);
if (sqlDialect != null) { if (sqlDialect != null) {
return sqlDialect; return sqlDialect;

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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; package org.springframework.boot.autoconfigure.orm.jpa;
import java.sql.DatabaseMetaData;
import java.util.Collections; import java.util.Collections;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.Map; import java.util.Map;
@ -70,7 +71,7 @@ final class DatabaseLookup {
return Database.DEFAULT; return Database.DEFAULT;
} }
try { try {
String url = JdbcUtils.extractDatabaseMetaData(dataSource, "getURL"); String url = JdbcUtils.extractDatabaseMetaData(dataSource, DatabaseMetaData::getURL);
DatabaseDriver driver = DatabaseDriver.fromJdbcUrl(url); DatabaseDriver driver = DatabaseDriver.fromJdbcUrl(url);
Database database = LOOKUP.get(driver); Database database = LOOKUP.get(driver);
if (database != null) { if (database != null) {

@ -407,8 +407,8 @@ class WebFluxAutoConfigurationTests {
assertThat(handlerMap).hasSize(2); assertThat(handlerMap).hasSize(2);
for (Object handler : handlerMap.values()) { for (Object handler : handlerMap.values()) {
if (handler instanceof ResourceWebHandler) { if (handler instanceof ResourceWebHandler) {
assertThat(((ResourceWebHandler) handler).getCacheControl()) assertThat(((ResourceWebHandler) handler).getCacheControl()).usingRecursiveComparison()
.isEqualToComparingFieldByField(CacheControl.maxAge(5, TimeUnit.SECONDS)); .isEqualTo(CacheControl.maxAge(5, TimeUnit.SECONDS));
} }
} }
}); });
@ -424,8 +424,8 @@ class WebFluxAutoConfigurationTests {
assertThat(handlerMap).hasSize(2); assertThat(handlerMap).hasSize(2);
for (Object handler : handlerMap.values()) { for (Object handler : handlerMap.values()) {
if (handler instanceof ResourceWebHandler) { if (handler instanceof ResourceWebHandler) {
assertThat(((ResourceWebHandler) handler).getCacheControl()).isEqualToComparingFieldByField( assertThat(((ResourceWebHandler) handler).getCacheControl()).usingRecursiveComparison()
CacheControl.maxAge(5, TimeUnit.SECONDS).proxyRevalidate()); .isEqualTo(CacheControl.maxAge(5, TimeUnit.SECONDS).proxyRevalidate());
} }
} }
}); });

@ -918,8 +918,8 @@ class WebMvcAutoConfigurationTests {
for (Object handler : handlerMap.keySet()) { for (Object handler : handlerMap.keySet()) {
if (handler instanceof ResourceHttpRequestHandler) { if (handler instanceof ResourceHttpRequestHandler) {
assertThat(((ResourceHttpRequestHandler) handler).getCacheSeconds()).isEqualTo(-1); assertThat(((ResourceHttpRequestHandler) handler).getCacheSeconds()).isEqualTo(-1);
assertThat(((ResourceHttpRequestHandler) handler).getCacheControl()) assertThat(((ResourceHttpRequestHandler) handler).getCacheControl()).usingRecursiveComparison()
.isEqualToComparingFieldByField(CacheControl.maxAge(5, TimeUnit.SECONDS).proxyRevalidate()); .isEqualTo(CacheControl.maxAge(5, TimeUnit.SECONDS).proxyRevalidate());
} }
} }
} }

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,6 +16,8 @@
package org.springframework.boot.jdbc; package org.springframework.boot.jdbc;
import java.sql.DatabaseMetaData;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.sql.DataSource; import javax.sql.DataSource;
@ -87,7 +89,7 @@ public abstract class AbstractDataSourceInitializer {
protected String getDatabaseName() { protected String getDatabaseName() {
try { try {
String productName = JdbcUtils.commonDatabaseName( String productName = JdbcUtils.commonDatabaseName(
JdbcUtils.extractDatabaseMetaData(this.dataSource, "getDatabaseProductName").toString()); JdbcUtils.extractDatabaseMetaData(this.dataSource, DatabaseMetaData::getDatabaseProductName));
DatabaseDriver databaseDriver = DatabaseDriver.fromProductName(productName); DatabaseDriver databaseDriver = DatabaseDriver.fromProductName(productName);
if (databaseDriver == DatabaseDriver.UNKNOWN) { if (databaseDriver == DatabaseDriver.UNKNOWN) {
throw new IllegalStateException("Unable to detect database type"); throw new IllegalStateException("Unable to detect database type");

Loading…
Cancel
Save