This is an automated email from the ASF dual-hosted git repository.
terrymanu 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 390d242714b Fix dangling commas in CONVERT YAML CONFIGURATION pool
properties (#40200)
390d242714b is described below
commit 390d242714b7286d9e008aa6d1a6d8a4485fc358
Author: Eunbin Son <[email protected]>
AuthorDate: Sun Oct 18 23:56:57 2026 +0900
Fix dangling commas in CONVERT YAML CONFIGURATION pool properties (#40200)
* Fix dangling commas in CONVERT YAML CONFIGURATION pool properties
* Use PropertiesBuilder and call-order helpers in convert YAML test
Build the custom pool props with PropertiesBuilder as required by
CODE_OF_CONDUCT, and place createConnectionOnlyDataSourceConfig and
createYamlConfig directly after their first caller in call order.
---
RELEASE-NOTES.md | 1 +
.../convert/ConvertYamlConfigurationExecutor.java | 29 +++---------
.../yaml/ConvertYamlConfigurationExecutorTest.java | 51 ++++++++++++++++++++++
3 files changed, 58 insertions(+), 23 deletions(-)
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index d6632d2fa95..4e9a49e1e12 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -63,6 +63,7 @@
1. DistSQL: Fix shadow DistSQL rejecting unquoted `SQL_HINT` algorithm type -
[#39873](https://github.com/apache/shardingsphere/pull/39873)
1. DistSQL: Fix duplicate key generator check when altering key generate
strategy - [#39997](https://github.com/apache/shardingsphere/pull/39997)
1. DistSQL: Fix `DROP SHARDING TABLE RULE` ignoring tables that differ only in
case - [#39996](https://github.com/apache/shardingsphere/pull/39996)
+1. DistSQL: Fix dangling commas in `CONVERT YAML CONFIGURATION` pool
properties - [#40200](https://github.com/apache/shardingsphere/pull/40200)
1. JDBC: Fix stale generated values leaking into prepared statement
executeBatch calls without pending batches -
[#38160](https://github.com/apache/shardingsphere/pull/38160)
1. JDBC: Fix MySQL-compatible typed string conversion for
`ResultSet#getObject(index, Class<T>)` -
[#38444](https://github.com/apache/shardingsphere/pull/38444)
1. JDBC: Fix statement close invalidating live result sets of other statements
on the same connection -
[#39503](https://github.com/apache/shardingsphere/pull/39503)
diff --git
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/configuration/convert/ConvertYamlConfigurationExecutor.java
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/configuration/convert/ConvertYamlConfigurationExecutor.java
index 3e40ff4df46..b34ccf872aa 100644
---
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/configuration/convert/ConvertYamlConfigurationExecutor.java
+++
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/configuration/convert/ConvertYamlConfigurationExecutor.java
@@ -47,9 +47,11 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
+import java.util.stream.Collectors;
/**
* Convert YAML configuration executor.
@@ -131,29 +133,10 @@ public final class ConvertYamlConfigurationExecutor
implements DistSQLQueryExecu
}
private String getDataSourcePoolProps(final PoolPropertySynonyms
poolPropertySynonyms, final CustomDataSourcePoolProperties
customDataSourcePoolProps) {
- StringBuilder result = new StringBuilder();
-
result.append(getDataSourcePoolProps(poolPropertySynonyms.getStandardProperties()));
- if (!customDataSourcePoolProps.getProperties().isEmpty()) {
- result.append(",");
-
result.append(getDataSourcePoolProps(customDataSourcePoolProps.getProperties()));
- }
- return result.toString();
- }
-
- private String getDataSourcePoolProps(final Map<String, Object> props) {
- StringBuilder result = new StringBuilder();
- Iterator<Entry<String, Object>> iterator = props.entrySet().iterator();
- while (iterator.hasNext()) {
- Entry<String, Object> entry = iterator.next();
- if (null == entry.getValue()) {
- continue;
- }
- result.append(String.format(DistSQLScriptConstants.PROPERTY,
entry.getKey(), entry.getValue()));
- if (iterator.hasNext()) {
- result.append(",");
- }
- }
- return result.toString();
+ Map<String, Object> props = new
LinkedHashMap<>(poolPropertySynonyms.getStandardProperties());
+ props.putAll(customDataSourcePoolProps.getProperties());
+ return props.entrySet().stream().filter(each -> null !=
each.getValue())
+ .map(each -> String.format(DistSQLScriptConstants.PROPERTY,
each.getKey(), each.getValue())).collect(Collectors.joining(","));
}
@SuppressWarnings({"rawtypes", "unchecked"})
diff --git
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/yaml/ConvertYamlConfigurationExecutorTest.java
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/yaml/ConvertYamlConfigurationExecutorTest.java
index 6742fe98932..fd117c0525e 100644
---
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/yaml/ConvertYamlConfigurationExecutorTest.java
+++
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/yaml/ConvertYamlConfigurationExecutorTest.java
@@ -28,6 +28,8 @@ import
org.apache.shardingsphere.distsql.statement.type.ral.queryable.convert.Co
import org.apache.shardingsphere.infra.exception.generic.FileIOException;
import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import org.apache.shardingsphere.infra.util.props.PropertiesBuilder;
+import org.apache.shardingsphere.infra.util.props.PropertiesBuilder.Property;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import
org.apache.shardingsphere.parser.rule.builder.DefaultSQLParserRuleConfigurationBuilder;
@@ -190,6 +192,26 @@ class ConvertYamlConfigurationExecutorTest {
"PASSWORD='12345678',",
"PROPERTIES('minPoolSize'='1','connectionTimeoutMilliseconds'='30000','maxLifetimeMilliseconds'='1800000',"
+
"'idleTimeoutMilliseconds'='60000','maxPoolSize'='50')",
+ ");")),
+ Arguments.of("without-max-pool-size",
createYamlConfigWithoutMaxPoolSize(), toExpectedRow(
+ "CREATE DATABASE without_max_pool_size_db;",
+ "USE without_max_pool_size_db;",
+ "",
+ "REGISTER STORAGE UNIT ds_0 (",
+
"URL='jdbc:mysql://127.0.0.1:3306/demo_convert_ds_0?useSSL=false',",
+ "USER='root',",
+ "PASSWORD='12345678',",
+
"PROPERTIES('minPoolSize'='1','connectionTimeoutMilliseconds'='30000')",
+ ");")),
+ Arguments.of("custom-pool-props-only",
createYamlConfigWithCustomPoolPropsOnly(), toExpectedRow(
+ "CREATE DATABASE custom_pool_props_only_db;",
+ "USE custom_pool_props_only_db;",
+ "",
+ "REGISTER STORAGE UNIT ds_0 (",
+
"URL='jdbc:mysql://127.0.0.1:3306/demo_convert_ds_0?useSSL=false',",
+ "USER='root',",
+ "PASSWORD='12345678',",
+ "PROPERTIES('foo1'='bar_1')",
");")));
}
@@ -222,6 +244,35 @@ class ConvertYamlConfigurationExecutorTest {
return result;
}
+ private static YamlDatabaseConfiguration
createYamlConfigWithoutMaxPoolSize() {
+ YamlDataSourceConfiguration dataSourceConfig =
createConnectionOnlyDataSourceConfig();
+ dataSourceConfig.setConnectionTimeoutMilliseconds(30000L);
+ dataSourceConfig.setMinPoolSize(1);
+ return createYamlConfig("without_max_pool_size_db", dataSourceConfig);
+ }
+
+ private static YamlDataSourceConfiguration
createConnectionOnlyDataSourceConfig() {
+ YamlDataSourceConfiguration result = new YamlDataSourceConfiguration();
+
result.setUrl("jdbc:mysql://127.0.0.1:3306/demo_convert_ds_0?useSSL=false");
+ result.setUsername("root");
+ result.setPassword("12345678");
+ return result;
+ }
+
+ private static YamlDatabaseConfiguration createYamlConfig(final String
databaseName, final YamlDataSourceConfiguration dataSourceConfig) {
+ YamlDatabaseConfiguration result = new YamlDatabaseConfiguration();
+ result.setDatabaseName(databaseName);
+ result.setDataSources(Collections.singletonMap("ds_0",
dataSourceConfig));
+ result.setRules(null);
+ return result;
+ }
+
+ private static YamlDatabaseConfiguration
createYamlConfigWithCustomPoolPropsOnly() {
+ YamlDataSourceConfiguration dataSourceConfig =
createConnectionOnlyDataSourceConfig();
+ dataSourceConfig.setCustomPoolProps(PropertiesBuilder.build(new
Property("foo_1", "bar_1")));
+ return createYamlConfig("custom_pool_props_only_db", dataSourceConfig);
+ }
+
private static Stream<Arguments> invalidInputCases() {
return Stream.of(
Arguments.of("missing-database-name",
"/conf/convert/database-without-database-name.yaml", true,