From 8fad59466cd1dc894e66180ea60a390d06fe9f1a Mon Sep 17 00:00:00 2001 From: Sreekara Reddy Date: Thu, 21 Sep 2023 03:29:47 +0530 Subject: [PATCH] Don't call setValidateConnectionOnBorrow on Oracle UCP datasource See gh-37501 --- .../boot/autoconfigure/jdbc/DataSourceConfiguration.java | 1 - .../autoconfigure/jdbc/DataSourceAutoConfigurationTests.java | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration.java index 6389876a24..dc6ec5d11b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration.java @@ -180,7 +180,6 @@ abstract class DataSourceConfiguration { throws SQLException { PoolDataSourceImpl dataSource = createDataSource(connectionDetails, PoolDataSourceImpl.class, properties.getClassLoader()); - dataSource.setValidateConnectionOnBorrow(true); if (StringUtils.hasText(properties.getName())) { dataSource.setConnectionPoolName(properties.getName()); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfigurationTests.java index 75cf075367..1e2cbca310 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfigurationTests.java @@ -152,10 +152,10 @@ class DataSourceAutoConfigurationTests { } @Test - void oracleUcpValidatesConnectionByDefault() { + void oracleUcpDoesNotValidateConnectionByDefault() { assertDataSource(PoolDataSourceImpl.class, Arrays.asList("com.zaxxer.hikari", "org.apache.tomcat", "org.apache.commons.dbcp2"), (dataSource) -> { - assertThat(dataSource.getValidateConnectionOnBorrow()).isTrue(); + assertThat(dataSource.getValidateConnectionOnBorrow()).isFalse(); // Use an internal ping when using an Oracle JDBC driver assertThat(dataSource.getSQLForValidateConnection()).isNull(); });