This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new e7cf24a879a Revert "Validate YAML dataSources before swap to avoid NPE
(#37448)" (#37449)
e7cf24a879a is described below
commit e7cf24a879a3bbd9e8c30040a7e2d21660adf47c
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Dec 20 21:32:52 2025 +0800
Revert "Validate YAML dataSources before swap to avoid NPE (#37448)"
(#37449)
This reverts commit 8f874b6e8ef535c57b6840b2f4549a16faaa2d14.
---
.../resource/YamlDataSourceConfigurationSwapper.java | 1 -
.../resource/YamlDataSourceConfigurationSwapperTest.java | 14 --------------
2 files changed, 15 deletions(-)
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/resource/YamlDataSourceConfigurationSwapper.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/resource/YamlDataSourceConfigurationSwapper.java
index 53f2dba06d4..e405cc2efa4 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/resource/YamlDataSourceConfigurationSwapper.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/resource/YamlDataSourceConfigurationSwapper.java
@@ -56,7 +56,6 @@ public final class YamlDataSourceConfigurationSwapper {
* @return data sources
*/
public Map<String, DataSource> swapToDataSources(final Map<String,
Map<String, Object>> yamlDataSources, final boolean cacheEnabled) {
- Preconditions.checkArgument(null != yamlDataSources &&
!yamlDataSources.isEmpty(), "Data sources can not be empty.");
return
DataSourcePoolCreator.create(yamlDataSources.entrySet().stream().collect(Collectors.toMap(Entry::getKey,
entry -> swapToDataSourcePoolProperties(entry.getValue()))), cacheEnabled);
}
diff --git
a/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/resource/YamlDataSourceConfigurationSwapperTest.java
b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/resource/YamlDataSourceConfigurationSwapperTest.java
index d06a133dbad..6a7d8d03de5 100644
---
a/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/resource/YamlDataSourceConfigurationSwapperTest.java
+++
b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/resource/YamlDataSourceConfigurationSwapperTest.java
@@ -23,7 +23,6 @@ import
org.apache.shardingsphere.test.infra.fixture.jdbc.MockedDataSource;
import org.junit.jupiter.api.Test;
import javax.sql.DataSource;
-import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -31,7 +30,6 @@ import java.util.Map;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertThrows;
class YamlDataSourceConfigurationSwapperTest {
@@ -51,18 +49,6 @@ class YamlDataSourceConfigurationSwapperTest {
assertThat(actual1.getPassword(), is("root"));
}
- @Test
- void assertSwapToDataSourcesWithNullConfig() {
- IllegalArgumentException actual =
assertThrows(IllegalArgumentException.class, () ->
swapper.swapToDataSources(null));
- assertThat(actual.getMessage(), is("Data sources can not be empty."));
- }
-
- @Test
- void assertSwapToDataSourcesWithEmptyConfig() {
- IllegalArgumentException actual =
assertThrows(IllegalArgumentException.class, () ->
swapper.swapToDataSources(Collections.emptyMap()));
- assertThat(actual.getMessage(), is("Data sources can not be empty."));
- }
-
@Test
void assertSwapToDataSourcePoolProperties() {
Map<String, Object> yamlConfig = new HashMap<>(3, 1F);