Deprecate commons-dbcp 1
Closes gh-6787
This commit is contained in:
@@ -44,7 +44,7 @@ public class DataSourceBuilder {
|
||||
private static final String[] DATA_SOURCE_TYPE_NAMES = new String[] {
|
||||
"org.apache.tomcat.jdbc.pool.DataSource",
|
||||
"com.zaxxer.hikari.HikariDataSource",
|
||||
"org.apache.commons.dbcp.BasicDataSource",
|
||||
"org.apache.commons.dbcp.BasicDataSource", //deprecated
|
||||
"org.apache.commons.dbcp2.BasicDataSource" };
|
||||
|
||||
private Class<? extends DataSource> type;
|
||||
|
||||
@@ -77,6 +77,7 @@ abstract class DataSourceConfiguration {
|
||||
|
||||
@ConditionalOnClass(org.apache.commons.dbcp.BasicDataSource.class)
|
||||
@ConditionalOnProperty(name = "spring.datasource.type", havingValue = "org.apache.commons.dbcp.BasicDataSource", matchIfMissing = true)
|
||||
@Deprecated
|
||||
static class Dbcp extends DataSourceConfiguration {
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2016 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.
|
||||
@@ -26,6 +26,7 @@ import org.apache.commons.dbcp.BasicDataSource;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.2.0
|
||||
*/
|
||||
@Deprecated
|
||||
public class CommonsDbcpDataSourcePoolMetadata
|
||||
extends AbstractDataSourcePoolMetadata<BasicDataSource> {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2016 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.
|
||||
@@ -19,7 +19,7 @@ package org.springframework.boot.autoconfigure.jdbc.metadata;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import org.apache.commons.dbcp.BasicDataSource;
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -78,7 +78,8 @@ public class DataSourcePoolMetadataProvidersConfiguration {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnClass(BasicDataSource.class)
|
||||
@ConditionalOnClass(org.apache.commons.dbcp.BasicDataSource.class)
|
||||
@Deprecated
|
||||
static class CommonsDbcpPoolDataSourceMetadataProviderConfiguration {
|
||||
|
||||
@Bean
|
||||
@@ -87,9 +88,9 @@ public class DataSourcePoolMetadataProvidersConfiguration {
|
||||
@Override
|
||||
public DataSourcePoolMetadata getDataSourcePoolMetadata(
|
||||
DataSource dataSource) {
|
||||
if (dataSource instanceof BasicDataSource) {
|
||||
if (dataSource instanceof org.apache.commons.dbcp.BasicDataSource) {
|
||||
return new CommonsDbcpDataSourcePoolMetadata(
|
||||
(BasicDataSource) dataSource);
|
||||
(org.apache.commons.dbcp.BasicDataSource) dataSource);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -99,7 +100,7 @@ public class DataSourcePoolMetadataProvidersConfiguration {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnClass(org.apache.commons.dbcp2.BasicDataSource.class)
|
||||
@ConditionalOnClass(BasicDataSource.class)
|
||||
static class CommonsDbcp2PoolDataSourceMetadataProviderConfiguration {
|
||||
|
||||
@Bean
|
||||
@@ -108,9 +109,9 @@ public class DataSourcePoolMetadataProvidersConfiguration {
|
||||
@Override
|
||||
public DataSourcePoolMetadata getDataSourcePoolMetadata(
|
||||
DataSource dataSource) {
|
||||
if (dataSource instanceof org.apache.commons.dbcp2.BasicDataSource) {
|
||||
if (dataSource instanceof BasicDataSource) {
|
||||
return new CommonsDbcp2DataSourcePoolMetadata(
|
||||
(org.apache.commons.dbcp2.BasicDataSource) dataSource);
|
||||
(BasicDataSource) dataSource);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Dave Syer
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Deprecated
|
||||
public class CommonsDbcpDataSourceConfigurationTests {
|
||||
|
||||
private static final String PREFIX = "spring.datasource.dbcp.";
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.logging.Logger;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import org.apache.commons.dbcp.BasicDataSource;
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -138,15 +138,19 @@ public class DataSourceAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void commonsDbcpIsFallback() throws Exception {
|
||||
BasicDataSource dataSource = autoConfigureDataSource(BasicDataSource.class,
|
||||
org.apache.commons.dbcp.BasicDataSource dataSource = autoConfigureDataSource(
|
||||
org.apache.commons.dbcp.BasicDataSource.class,
|
||||
"org.apache.tomcat", "com.zaxxer.hikari");
|
||||
assertThat(dataSource.getUrl()).isEqualTo("jdbc:hsqldb:mem:testdb");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void commonsDbcpValidatesConnectionByDefault() {
|
||||
BasicDataSource dataSource = autoConfigureDataSource(BasicDataSource.class,
|
||||
org.apache.commons.dbcp.BasicDataSource dataSource = autoConfigureDataSource(
|
||||
org.apache.commons.dbcp.BasicDataSource.class,
|
||||
"org.apache.tomcat", "com.zaxxer.hikari");
|
||||
assertThat(dataSource.getTestOnBorrow()).isTrue();
|
||||
assertThat(dataSource.getValidationQuery())
|
||||
@@ -155,9 +159,8 @@ public class DataSourceAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void commonsDbcp2IsFallback() throws Exception {
|
||||
org.apache.commons.dbcp2.BasicDataSource dataSource = autoConfigureDataSource(
|
||||
org.apache.commons.dbcp2.BasicDataSource.class, "org.apache.tomcat",
|
||||
"com.zaxxer.hikari", "org.apache.commons.dbcp.");
|
||||
BasicDataSource dataSource = autoConfigureDataSource(BasicDataSource.class,
|
||||
"org.apache.tomcat", "com.zaxxer.hikari", "org.apache.commons.dbcp.");
|
||||
assertThat(dataSource.getUrl()).isEqualTo("jdbc:hsqldb:mem:testdb");
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.Random;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.dbcp.BasicDataSource;
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.jmx.export.MBeanExporter;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests for {@link JndiDataSourceAutoConfiguration}
|
||||
@@ -120,7 +121,7 @@ public class JndiDataSourceAutoConfigurationTests {
|
||||
@Test
|
||||
public void standardDataSourceIsNotExcludedFromExport()
|
||||
throws IllegalStateException, NamingException {
|
||||
DataSource dataSource = new org.apache.commons.dbcp.BasicDataSource();
|
||||
DataSource dataSource = mock(DataSource.class);
|
||||
configureJndi("foo", dataSource);
|
||||
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.boot.autoconfigure.jdbc;
|
||||
|
||||
import org.apache.commons.dbcp.BasicDataSource;
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
|
||||
/**
|
||||
* {@link BasicDataSource} used for testing.
|
||||
|
||||
@@ -27,6 +27,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Deprecated
|
||||
public class CommonsDbcpDataSourcePoolMetadataTests
|
||||
extends AbstractDataSourcePoolMetadataTests<CommonsDbcpDataSourcePoolMetadata> {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user