This is an automated email from the ASF dual-hosted git repository.

menghaoran 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 18b6e57b7f2 Refactor PipelineJobNotFoundException (#20176)
18b6e57b7f2 is described below

commit 18b6e57b7f2aaf3633b51bb1d236987abccb9170
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Aug 15 01:01:03 2022 +0800

    Refactor PipelineJobNotFoundException (#20176)
---
 .../exception/sql/vendor/ShardingSphereVendorError.java     |  2 --
 .../pipeline/core/api/impl/AbstractPipelineJobAPIImpl.java  |  2 +-
 .../core/exception/PipelineJobNotFoundException.java        | 13 +++++--------
 .../proxy/frontend/mysql/err/MySQLErrPacketFactory.java     |  8 ++------
 4 files changed, 8 insertions(+), 17 deletions(-)

diff --git 
a/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/sql/vendor/ShardingSphereVendorError.java
 
b/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/sql/vendor/ShardingSphereVendorError.java
index 5a34068da7e..ea6f032b17f 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/sql/vendor/ShardingSphereVendorError.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/sql/vendor/ShardingSphereVendorError.java
@@ -29,8 +29,6 @@ import 
org.apache.shardingsphere.infra.util.exception.sql.sqlstate.XOpenSQLState
 @Getter
 public enum ShardingSphereVendorError implements VendorError {
     
-    SCALING_JOB_NOT_EXIST(XOpenSQLState.GENERAL_ERROR, 1201, "Scaling job `%s` 
does not exist"),
-    
     UNKNOWN_EXCEPTION(XOpenSQLState.SYNTAX_ERROR, 1999, "Unknown exception: 
%s"),
     
     UNSUPPORTED_SQL(XOpenSQLState.SYNTAX_ERROR, 1235, "Unsupported SQL: %s");
diff --git 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/api/impl/AbstractPipelineJobAPIImpl.java
 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/api/impl/AbstractPipelineJobAPIImpl.java
index a858e15773d..7b2797395a9 100644
--- 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/api/impl/AbstractPipelineJobAPIImpl.java
+++ 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/api/impl/AbstractPipelineJobAPIImpl.java
@@ -117,7 +117,7 @@ public abstract class AbstractPipelineJobAPIImpl implements 
PipelineJobAPI {
     protected final JobConfigurationPOJO getElasticJobConfigPOJO(final String 
jobId) {
         JobConfigurationPOJO result = 
PipelineAPIFactory.getJobConfigurationAPI().getJobConfiguration(jobId);
         if (null == result) {
-            throw new PipelineJobNotFoundException(String.format("Can not find 
scaling job %s", jobId), jobId);
+            throw new PipelineJobNotFoundException(jobId);
         }
         return result;
     }
diff --git 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/exception/PipelineJobNotFoundException.java
 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/exception/PipelineJobNotFoundException.java
index aa3f5177605..7b8f3993eaf 100644
--- 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/exception/PipelineJobNotFoundException.java
+++ 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/exception/PipelineJobNotFoundException.java
@@ -17,20 +17,17 @@
 
 package org.apache.shardingsphere.data.pipeline.core.exception;
 
-import lombok.Getter;
+import 
org.apache.shardingsphere.infra.util.exception.sql.ShardingSphereSQLException;
+import 
org.apache.shardingsphere.infra.util.exception.sql.sqlstate.XOpenSQLState;
 
 /**
  * Pipeline job not found exception.
  */
-@Getter
-public final class PipelineJobNotFoundException extends RuntimeException {
+public final class PipelineJobNotFoundException extends 
ShardingSphereSQLException {
     
     private static final long serialVersionUID = -903289953649758722L;
     
-    private final String jobId;
-    
-    public PipelineJobNotFoundException(final String message, final String 
jobId) {
-        super(message);
-        this.jobId = jobId;
+    public PipelineJobNotFoundException(final String jobId) {
+        super(XOpenSQLState.GENERAL_ERROR, 1201, "Can not find pipeline job 
`%s`", jobId);
     }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
index 4ae77fac28a..3ffb80068f7 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
@@ -20,14 +20,13 @@ package org.apache.shardingsphere.proxy.frontend.mysql.err;
 import com.google.common.base.Strings;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
-import 
org.apache.shardingsphere.data.pipeline.core.exception.PipelineJobNotFoundException;
 import 
org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLErrPacket;
 import org.apache.shardingsphere.error.SQLExceptionHandler;
-import 
org.apache.shardingsphere.infra.util.exception.sql.vendor.ShardingSphereVendorError;
 import org.apache.shardingsphere.error.mysql.code.MySQLVendorError;
 import 
org.apache.shardingsphere.infra.util.exception.ShardingSphereInsideException;
-import 
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.exception.DistSQLVendorError;
+import 
org.apache.shardingsphere.infra.util.exception.sql.vendor.ShardingSphereVendorError;
 import 
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.exception.DistSQLException;
+import 
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.exception.DistSQLVendorError;
 import 
org.apache.shardingsphere.proxy.frontend.exception.UnsupportedPreparedStatementException;
 
 import java.nio.charset.UnsupportedCharsetException;
@@ -62,9 +61,6 @@ public final class MySQLErrPacketFactory {
         if (cause instanceof UnsupportedPreparedStatementException) {
             return new MySQLErrPacket(1, MySQLVendorError.ER_UNSUPPORTED_PS);
         }
-        if (cause instanceof PipelineJobNotFoundException) {
-            return new MySQLErrPacket(1, 
ShardingSphereVendorError.SCALING_JOB_NOT_EXIST, 
((PipelineJobNotFoundException) cause).getJobId());
-        }
         if (cause instanceof UnsupportedCharsetException) {
             return new MySQLErrPacket(1, 
MySQLVendorError.ER_UNKNOWN_CHARACTER_SET, cause.getMessage());
         }

Reply via email to