This is an automated email from the ASF dual-hosted git repository.
panjuan 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 be2e878c98c Refactor DataSourcePoolProperties (#28046)
be2e878c98c is described below
commit be2e878c98ca47c506d7ce7e3f179746c1b150eb
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Aug 12 10:47:09 2023 +0800
Refactor DataSourcePoolProperties (#28046)
---
.../datasource/pool/props/DataSourcePoolProperties.java | 13 +++++++------
.../props/InvalidDataSourcePoolPropertiesException.java | 6 ++++--
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git
a/infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/props/DataSourcePoolProperties.java
b/infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/props/DataSourcePoolProperties.java
index 69507941cb8..09b59b5816c 100644
---
a/infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/props/DataSourcePoolProperties.java
+++
b/infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/props/DataSourcePoolProperties.java
@@ -108,17 +108,18 @@ public final class DataSourcePoolProperties {
}
private boolean equalsByProperties(final DataSourcePoolProperties props) {
- if (!poolClassName.equals(props.poolClassName)) {
- return false;
- }
+ return poolClassName.equals(props.poolClassName) &&
equalsByLocalProperties(props.getAllLocalProperties());
+ }
+
+ private boolean equalsByLocalProperties(final Map<String, Object>
localProps) {
for (Entry<String, Object> entry : getAllLocalProperties().entrySet())
{
- if (!props.getAllLocalProperties().containsKey(entry.getKey())) {
+ if (!localProps.containsKey(entry.getKey())) {
continue;
}
if (entry.getValue() instanceof Map) {
- return
entry.getValue().equals(props.getAllLocalProperties().get(entry.getKey()));
+ return entry.getValue().equals(localProps.get(entry.getKey()));
}
- if
(!String.valueOf(entry.getValue()).equals(String.valueOf(props.getAllLocalProperties().get(entry.getKey()))))
{
+ if
(!String.valueOf(entry.getValue()).equals(String.valueOf(localProps.get(entry.getKey()))))
{
return false;
}
}
diff --git
a/infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/props/InvalidDataSourcePoolPropertiesException.java
b/infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/props/InvalidDataSourcePoolPropertiesException.java
index 08ca9083a94..a98299b669c 100644
---
a/infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/props/InvalidDataSourcePoolPropertiesException.java
+++
b/infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/props/InvalidDataSourcePoolPropertiesException.java
@@ -17,14 +17,16 @@
package org.apache.shardingsphere.infra.datasource.pool.props;
+import
org.apache.shardingsphere.infra.exception.core.internal.ShardingSphereInternalException;
+
/**
* Invalid data source pool properties exception.
*/
-public final class InvalidDataSourcePoolPropertiesException extends Exception {
+public final class InvalidDataSourcePoolPropertiesException extends
ShardingSphereInternalException {
private static final long serialVersionUID = -7221138369057943935L;
public InvalidDataSourcePoolPropertiesException(final String
dataSourceName, final String errorMessage) {
- super(String.format("Invalid data source `%s`, error message is: %s",
dataSourceName, errorMessage));
+ super("Invalid data source `%s`, error message is: %s",
dataSourceName, errorMessage);
}
}