This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 116bef3d010 Fix datasource properties comparison not right when
properties are map type. (#22548)
116bef3d010 is described below
commit 116bef3d01083deeaf98459c3f185f9478b244fa
Author: zhaojinchao <[email protected]>
AuthorDate: Thu Dec 1 15:42:00 2022 +0800
Fix datasource properties comparison not right when properties are map
type. (#22548)
* Fix datasource properties comparison not right when properties are map
type
* Adjustment code
* Add some unit test
---
.../infra/datasource/props/DataSourceProperties.java | 3 +++
.../infra/datasource/props/DataSourcePropertiesTest.java | 9 +++++++++
2 files changed, 12 insertions(+)
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/datasource/props/DataSourceProperties.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/datasource/props/DataSourceProperties.java
index 7460aed4f22..0dd2d1ef53e 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/datasource/props/DataSourceProperties.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/datasource/props/DataSourceProperties.java
@@ -104,6 +104,9 @@ public final class DataSourceProperties {
if
(!dataSourceProps.getAllLocalProperties().containsKey(entry.getKey())) {
continue;
}
+ if (entry.getValue() instanceof Map) {
+ return
entry.getValue().equals(dataSourceProps.getAllLocalProperties().get(entry.getKey()));
+ }
if
(!String.valueOf(entry.getValue()).equals(String.valueOf(dataSourceProps.getAllLocalProperties().get(entry.getKey()))))
{
return false;
}
diff --git
a/infra/common/src/test/java/org/apache/shardingsphere/infra/datasource/props/DataSourcePropertiesTest.java
b/infra/common/src/test/java/org/apache/shardingsphere/infra/datasource/props/DataSourcePropertiesTest.java
index a311714d9bb..6b8f48a03ab 100644
---
a/infra/common/src/test/java/org/apache/shardingsphere/infra/datasource/props/DataSourcePropertiesTest.java
+++
b/infra/common/src/test/java/org/apache/shardingsphere/infra/datasource/props/DataSourcePropertiesTest.java
@@ -135,6 +135,15 @@ public final class DataSourcePropertiesTest {
private Map<String, Object> createUserProperties(final String username) {
Map<String, Object> result = new LinkedHashMap<>(1, 1);
result.put("username", username);
+ result.put("dataSourceProperties", getDataSourceProperties());
+ return result;
+ }
+
+ private Map<String, String> getDataSourceProperties() {
+ Map<String, String> result = new LinkedHashMap<>(3, 1);
+ result.put("maintainTimeStats", "false");
+ result.put("rewriteBatchedStatements", "true");
+ result.put("useLocalSessionState", "true");
return result;
}
}