This is an automated email from the ASF dual-hosted git repository.
jianglongtao 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 0a5c8f0dd55 Refactor BackendException to impl
ShardingSphereInsideException (#19997)
0a5c8f0dd55 is described below
commit 0a5c8f0dd55b43718e675e4fe3ce3dc4b24a0f20
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Aug 9 01:13:47 2022 +0800
Refactor BackendException to impl ShardingSphereInsideException (#19997)
* Refactor BackendException to impl ShardingSphereInsideException
* Refactor BackendException to impl ShardingSphereInsideException
---
.../util/exception/ShardingSphereInsideException.java | 5 ++++-
.../infra/util/props/TypedPropertyValue.java | 4 ++--
.../infra/util/props/TypedPropertyValueTest.java | 14 +++++++-------
.../proxy/backend/exception/BackendException.java | 4 +++-
4 files changed, 16 insertions(+), 11 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/ShardingSphereInsideException.java
index e4bf2356f62..a3b30bc75fa 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/ShardingSphereInsideException.java
@@ -17,10 +17,13 @@
package org.apache.shardingsphere.infra.util.exception;
+import lombok.NoArgsConstructor;
+
/**
* ShardingSphere inside exception.
*/
-public abstract class ShardingSphereInsideException extends Exception {
+@NoArgsConstructor
+public abstract class ShardingSphereInsideException extends RuntimeException {
private static final long serialVersionUID = -8238061892944243621L;
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 f918e636e0c..54b95af83d6 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)
throws TypedPropertyValueException {
+ public TypedPropertyValue(final TypedPropertyKey key, final String value) {
this.value = createTypedValue(key, value);
}
- private Object createTypedValue(final TypedPropertyKey key, final String
value) throws TypedPropertyValueException {
+ private Object createTypedValue(final TypedPropertyKey key, final String
value) {
if (boolean.class == key.getType() || Boolean.class == key.getType()) {
return Boolean.valueOf(value);
}
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 3b7273f9a87..d67b814677b 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() throws TypedPropertyValueException {
+ public void assertGetBooleanValue() {
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() throws
TypedPropertyValueException {
+ public void assertGetInvalidBooleanValue() {
assertFalse((Boolean) new
TypedPropertyValue(TypedPropertyKeyFixture.BOOLEAN_VALUE, "test").getValue());
}
@Test
- public void assertGetIntValue() throws TypedPropertyValueException {
+ public void assertGetIntValue() {
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() throws TypedPropertyValueException {
+ public void assertGetInvalidIntValue() {
new TypedPropertyValue(TypedPropertyKeyFixture.INT_VALUE, "test");
}
@Test
- public void assertGetLongValue() throws TypedPropertyValueException {
+ public void assertGetLongValue() {
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() throws TypedPropertyValueException
{
+ public void assertGetInvalidLongValue() {
new TypedPropertyValue(TypedPropertyKeyFixture.LONG_VALUE, "test");
}
@Test
- public void assertGetStringValue() throws TypedPropertyValueException {
+ public void assertGetStringValue() {
assertThat(new
TypedPropertyValue(TypedPropertyKeyFixture.STRING_VALUE,
"new_value").getValue(), is("new_value"));
}
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/BackendException.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/BackendException.java
index f174149bf39..a991b257977 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/BackendException.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/BackendException.java
@@ -17,10 +17,12 @@
package org.apache.shardingsphere.proxy.backend.exception;
+import
org.apache.shardingsphere.infra.util.exception.ShardingSphereInsideException;
+
/**
* Backend exception.
*/
-public abstract class BackendException extends RuntimeException {
+public abstract class BackendException extends ShardingSphereInsideException {
private static final long serialVersionUID = -2361593557266150160L;
}