You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by tu...@apache.org on 2022/09/02 15:44:01 UTC
[shardingsphere] branch master updated: Rename ShardingSphereInsideException to ShardingSphereInternalException (#20743)
This is an automated email from the ASF dual-hosted git repository.
tuichenchuxin 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 e9e99710a88 Rename ShardingSphereInsideException to ShardingSphereInternalException (#20743)
e9e99710a88 is described below
commit e9e99710a883588e97b02ff6698d51fd9816db5c
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Fri Sep 2 23:43:52 2022 +0800
Rename ShardingSphereInsideException to ShardingSphereInternalException (#20743)
* Rename ShardingSphereInsideException to ShardingSphereInternalException
* Rename ShardingSphereInsideException to ShardingSphereInternalException
---
...Exception.java => ShardingSphereInternalException.java} | 10 +++++-----
.../infra/util/props/TypedPropertyValue.java | 4 ++--
.../util/props/exception/TypedPropertyValueException.java | 4 ++--
...nTest.java => ShardingSphereInternalExceptionTest.java} | 10 +++++-----
...re.java => ShardingSphereInternalExceptionFixture.java} | 10 +++++-----
.../infra/util/props/TypedPropertyValueTest.java | 14 +++++++-------
.../proxy/frontend/command/CommandExecutorTask.java | 5 +++--
.../proxy/frontend/exception/ExpectedExceptions.java | 2 --
.../proxy/frontend/exception/ExpectedExceptionsTest.java | 4 ++--
9 files changed, 31 insertions(+), 32 deletions(-)
diff --git a/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInsideException.java b/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInternalException.java
similarity index 75%
rename from shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInsideException.java
rename to shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInternalException.java
index a3b30bc75fa..dd39c5e07e9 100644
--- a/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInsideException.java
+++ b/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInternalException.java
@@ -20,22 +20,22 @@ package org.apache.shardingsphere.infra.util.exception;
import lombok.NoArgsConstructor;
/**
- * ShardingSphere inside exception.
+ * ShardingSphere internal exception.
*/
@NoArgsConstructor
-public abstract class ShardingSphereInsideException extends RuntimeException {
+public abstract class ShardingSphereInternalException extends Exception {
private static final long serialVersionUID = -8238061892944243621L;
- public ShardingSphereInsideException(final String errorMessage, final Object... args) {
+ public ShardingSphereInternalException(final String errorMessage, final Object... args) {
super(String.format(errorMessage, args));
}
- public ShardingSphereInsideException(final Exception cause) {
+ public ShardingSphereInternalException(final Exception cause) {
super(cause);
}
- public ShardingSphereInsideException(final String message, final Exception cause) {
+ public ShardingSphereInternalException(final String message, final Exception cause) {
super(message, cause);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/props/TypedPropertyValue.java b/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/props/TypedPropertyValue.java
index 54b95af83d6..f918e636e0c 100644
--- a/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/props/TypedPropertyValue.java
+++ b/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/props/TypedPropertyValue.java
@@ -28,11 +28,11 @@ public final class TypedPropertyValue {
private final Object value;
- public TypedPropertyValue(final TypedPropertyKey key, final String value) {
+ public TypedPropertyValue(final TypedPropertyKey key, final String value) throws TypedPropertyValueException {
this.value = createTypedValue(key, value);
}
- private Object createTypedValue(final TypedPropertyKey key, final String value) {
+ private Object createTypedValue(final TypedPropertyKey key, final String value) throws TypedPropertyValueException {
if (boolean.class == key.getType() || Boolean.class == key.getType()) {
return Boolean.valueOf(value);
}
diff --git a/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/props/exception/TypedPropertyValueException.java b/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/props/exception/TypedPropertyValueException.java
index f0eca7c6429..6d01b204728 100644
--- a/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/props/exception/TypedPropertyValueException.java
+++ b/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/props/exception/TypedPropertyValueException.java
@@ -17,13 +17,13 @@
package org.apache.shardingsphere.infra.util.props.exception;
-import org.apache.shardingsphere.infra.util.exception.ShardingSphereInsideException;
+import org.apache.shardingsphere.infra.util.exception.ShardingSphereInternalException;
import org.apache.shardingsphere.infra.util.props.TypedPropertyKey;
/**
* Typed property value exception.
*/
-public final class TypedPropertyValueException extends ShardingSphereInsideException {
+public final class TypedPropertyValueException extends ShardingSphereInternalException {
private static final long serialVersionUID = -2989212435757964906L;
diff --git a/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInsideExceptionTest.java b/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInternalExceptionTest.java
similarity index 76%
rename from shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInsideExceptionTest.java
rename to shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInternalExceptionTest.java
index 71098cd159f..1d80401386c 100644
--- a/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInsideExceptionTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInternalExceptionTest.java
@@ -17,28 +17,28 @@
package org.apache.shardingsphere.infra.util.exception;
-import org.apache.shardingsphere.infra.util.exception.fixture.ShardingSphereInsideExceptionFixture;
+import org.apache.shardingsphere.infra.util.exception.fixture.ShardingSphereInternalExceptionFixture;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public final class ShardingSphereInsideExceptionTest {
+public final class ShardingSphereInternalExceptionTest {
@Test
public void assertGetMessage() {
- assertThat(new ShardingSphereInsideExceptionFixture("Test").getMessage(), is("Fixture error message: Test"));
+ assertThat(new ShardingSphereInternalExceptionFixture("Test").getMessage(), is("Fixture error message: Test"));
}
@Test
public void assertGetCause() {
RuntimeException cause = new RuntimeException("Test");
- assertThat(new ShardingSphereInsideExceptionFixture(cause).getCause(), is(cause));
+ assertThat(new ShardingSphereInternalExceptionFixture(cause).getCause(), is(cause));
}
@Test
public void assertGetCauseWithMessage() {
RuntimeException cause = new RuntimeException("Test");
- assertThat(new ShardingSphereInsideExceptionFixture("Test", cause).getCause(), is(cause));
+ assertThat(new ShardingSphereInternalExceptionFixture("Test", cause).getCause(), is(cause));
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/fixture/ShardingSphereInsideExceptionFixture.java b/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/fixture/ShardingSphereInternalExceptionFixture.java
similarity index 75%
rename from shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/fixture/ShardingSphereInsideExceptionFixture.java
rename to shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/fixture/ShardingSphereInternalExceptionFixture.java
index 83e65e606be..11c5b1260e0 100644
--- a/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/fixture/ShardingSphereInsideExceptionFixture.java
+++ b/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/fixture/ShardingSphereInternalExceptionFixture.java
@@ -17,21 +17,21 @@
package org.apache.shardingsphere.infra.util.exception.fixture;
-import org.apache.shardingsphere.infra.util.exception.ShardingSphereInsideException;
+import org.apache.shardingsphere.infra.util.exception.ShardingSphereInternalException;
-public final class ShardingSphereInsideExceptionFixture extends ShardingSphereInsideException {
+public final class ShardingSphereInternalExceptionFixture extends ShardingSphereInternalException {
private static final long serialVersionUID = 3759417279204541147L;
- public ShardingSphereInsideExceptionFixture(final String message) {
+ public ShardingSphereInternalExceptionFixture(final String message) {
super("Fixture error message: %s", message);
}
- public ShardingSphereInsideExceptionFixture(final String message, final Exception cause) {
+ public ShardingSphereInternalExceptionFixture(final String message, final Exception cause) {
super(message, cause);
}
- public ShardingSphereInsideExceptionFixture(final Exception cause) {
+ public ShardingSphereInternalExceptionFixture(final Exception cause) {
super(cause);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/props/TypedPropertyValueTest.java b/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/props/TypedPropertyValueTest.java
index d67b814677b..3b7273f9a87 100644
--- a/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/props/TypedPropertyValueTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/props/TypedPropertyValueTest.java
@@ -29,40 +29,40 @@ import static org.junit.Assert.assertTrue;
public final class TypedPropertyValueTest {
@Test
- public void assertGetBooleanValue() {
+ public void assertGetBooleanValue() throws TypedPropertyValueException {
assertTrue((Boolean) new TypedPropertyValue(TypedPropertyKeyFixture.BOOLEAN_VALUE, Boolean.TRUE.toString()).getValue());
assertTrue((Boolean) new TypedPropertyValue(TypedPropertyKeyFixture.BOOLEAN_OBJECT_VALUE, Boolean.TRUE.toString()).getValue());
}
@Test
- public void assertGetInvalidBooleanValue() {
+ public void assertGetInvalidBooleanValue() throws TypedPropertyValueException {
assertFalse((Boolean) new TypedPropertyValue(TypedPropertyKeyFixture.BOOLEAN_VALUE, "test").getValue());
}
@Test
- public void assertGetIntValue() {
+ public void assertGetIntValue() throws TypedPropertyValueException {
assertThat(new TypedPropertyValue(TypedPropertyKeyFixture.INT_VALUE, "1000").getValue(), is(1000));
assertThat(new TypedPropertyValue(TypedPropertyKeyFixture.INT_OBJECT_VALUE, "1000").getValue(), is(1000));
}
@Test(expected = TypedPropertyValueException.class)
- public void assertGetInvalidIntValue() {
+ public void assertGetInvalidIntValue() throws TypedPropertyValueException {
new TypedPropertyValue(TypedPropertyKeyFixture.INT_VALUE, "test");
}
@Test
- public void assertGetLongValue() {
+ public void assertGetLongValue() throws TypedPropertyValueException {
assertThat(new TypedPropertyValue(TypedPropertyKeyFixture.LONG_VALUE, "10000").getValue(), is(10000L));
assertThat(new TypedPropertyValue(TypedPropertyKeyFixture.LONG_OBJECT_VALUE, "10000").getValue(), is(10000L));
}
@Test(expected = TypedPropertyValueException.class)
- public void assertGetInvalidLongValue() {
+ public void assertGetInvalidLongValue() throws TypedPropertyValueException {
new TypedPropertyValue(TypedPropertyKeyFixture.LONG_VALUE, "test");
}
@Test
- public void assertGetStringValue() {
+ public void assertGetStringValue() throws TypedPropertyValueException {
assertThat(new TypedPropertyValue(TypedPropertyKeyFixture.STRING_VALUE, "new_value").getValue(), is("new_value"));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
index 937e9919fe2..0d6f425dc33 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
@@ -26,8 +26,9 @@ import org.apache.shardingsphere.db.protocol.packet.CommandPacket;
import org.apache.shardingsphere.db.protocol.packet.CommandPacketType;
import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
import org.apache.shardingsphere.db.protocol.payload.PacketPayload;
+import org.apache.shardingsphere.dialect.exception.SQLDialectException;
import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
-import org.apache.shardingsphere.infra.util.exception.ShardingSphereInsideException;
+import org.apache.shardingsphere.infra.util.exception.sql.ShardingSphereSQLException;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.BackendConnectionException;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
@@ -116,7 +117,7 @@ public final class CommandExecutorTask implements Runnable {
commandExecuteEngine.writeQueryData(context, connectionSession.getBackendConnection(), (QueryCommandExecutor) commandExecutor, responsePackets.size());
}
return true;
- } catch (final SQLException | ShardingSphereInsideException ex) {
+ } catch (final SQLException | ShardingSphereSQLException | SQLDialectException ex) {
databaseProtocolFrontendEngine.handleException(connectionSession, ex);
throw ex;
} finally {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/exception/ExpectedExceptions.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/exception/ExpectedExceptions.java
index 44ef0d7a231..edc4d694bb4 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/exception/ExpectedExceptions.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/exception/ExpectedExceptions.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.proxy.frontend.exception;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.dialect.exception.SQLDialectException;
-import org.apache.shardingsphere.infra.util.exception.ShardingSphereInsideException;
import org.apache.shardingsphere.infra.util.exception.ShardingSphereServerException;
import org.apache.shardingsphere.infra.util.exception.sql.ShardingSphereSQLException;
@@ -37,7 +36,6 @@ public final class ExpectedExceptions {
static {
EXCEPTIONS.add(ShardingSphereServerException.class);
- EXCEPTIONS.add(ShardingSphereInsideException.class);
EXCEPTIONS.add(ShardingSphereSQLException.class);
EXCEPTIONS.add(SQLDialectException.class);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/exception/ExpectedExceptionsTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/exception/ExpectedExceptionsTest.java
index d27a022128c..934e9b174cf 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/exception/ExpectedExceptionsTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/exception/ExpectedExceptionsTest.java
@@ -18,8 +18,8 @@
package org.apache.shardingsphere.proxy.frontend.exception;
import org.apache.shardingsphere.dialect.exception.SQLDialectException;
+import org.apache.shardingsphere.infra.util.exception.ShardingSphereInternalException;
import org.apache.shardingsphere.infra.util.exception.ShardingSphereServerException;
-import org.apache.shardingsphere.infra.util.exception.ShardingSphereInsideException;
import org.apache.shardingsphere.infra.util.exception.sql.ShardingSphereSQLException;
import org.junit.Test;
@@ -31,7 +31,6 @@ public final class ExpectedExceptionsTest {
@Test
public void assertIsExpected() {
assertTrue(ExpectedExceptions.isExpected(ShardingSphereServerException.class));
- assertTrue(ExpectedExceptions.isExpected(ShardingSphereInsideException.class));
assertTrue(ExpectedExceptions.isExpected(SQLDialectException.class));
assertTrue(ExpectedExceptions.isExpected(ShardingSphereSQLException.class));
}
@@ -40,5 +39,6 @@ public final class ExpectedExceptionsTest {
public void assertIsNotExpected() {
assertFalse(ExpectedExceptions.isExpected(Exception.class));
assertFalse(ExpectedExceptions.isExpected(IllegalArgumentException.class));
+ assertFalse(ExpectedExceptions.isExpected(ShardingSphereInternalException.class));
}
}