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 b292bd62198 Improve exception catch for `ADD RESOURCE` & `ALTER
RESOURCE`. (#19349)
b292bd62198 is described below
commit b292bd62198ac3904ad93e4d01ae01790c65d1c8
Author: Raigor <[email protected]>
AuthorDate: Tue Jul 19 23:55:19 2022 +0800
Improve exception catch for `ADD RESOURCE` & `ALTER RESOURCE`. (#19349)
---
.../text/distsql/rdl/resource/AddResourceBackendHandler.java | 6 +++---
.../text/distsql/rdl/resource/AlterResourceBackendHandler.java | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AddResourceBackendHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AddResourceBackendHandler.java
index 787bf8893a4..73e598a1325 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AddResourceBackendHandler.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AddResourceBackendHandler.java
@@ -26,12 +26,14 @@ import
org.apache.shardingsphere.infra.datasource.props.DataSourcePropertiesVali
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import
org.apache.shardingsphere.infra.distsql.exception.resource.DuplicateResourceException;
import
org.apache.shardingsphere.infra.distsql.exception.resource.InvalidResourcesException;
+import org.apache.shardingsphere.infra.exception.ShardingSphereException;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import
org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import
org.apache.shardingsphere.proxy.backend.text.DatabaseRequiredBackendHandler;
+import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -61,9 +63,7 @@ public final class AddResourceBackendHandler extends
DatabaseRequiredBackendHand
validator.validate(dataSourcePropsMap);
try {
ProxyContext.getInstance().getContextManager().updateResources(databaseName,
dataSourcePropsMap);
- // CHECKSTYLE:OFF
- } catch (final Exception ex) {
- // CHECKSTYLE:ON
+ } catch (final SQLException | ShardingSphereException ex) {
log.error("Add resource failed", ex);
throw new
InvalidResourcesException(Collections.singleton(ex.getMessage()));
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AlterResourceBackendHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AlterResourceBackendHandler.java
index 533839b81d5..4ccc8869764 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AlterResourceBackendHandler.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AlterResourceBackendHandler.java
@@ -32,6 +32,7 @@ import
org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import
org.apache.shardingsphere.infra.distsql.exception.resource.DuplicateResourceException;
import
org.apache.shardingsphere.infra.distsql.exception.resource.InvalidResourcesException;
import
org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.exception.ShardingSphereException;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import
org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
@@ -39,6 +40,7 @@ import
org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import
org.apache.shardingsphere.proxy.backend.text.DatabaseRequiredBackendHandler;
import javax.sql.DataSource;
+import java.sql.SQLException;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
@@ -68,9 +70,7 @@ public final class AlterResourceBackendHandler extends
DatabaseRequiredBackendHa
validator.validate(dataSourcePropsMap);
try {
ProxyContext.getInstance().getContextManager().updateResources(databaseName,
dataSourcePropsMap);
- // CHECKSTYLE:OFF
- } catch (final Exception ex) {
- // CHECKSTYLE:ON
+ } catch (final SQLException | ShardingSphereException ex) {
log.error("Alter resource failed", ex);
throw new
InvalidResourcesException(Collections.singleton(ex.getMessage()));
}