You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2020/10/04 08:42:46 UTC
[shardingsphere] branch master updated: Remove useless
@SneakyThrows (#7697)
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 3fdee3f Remove useless @SneakyThrows (#7697)
3fdee3f is described below
commit 3fdee3f2341e32a55122c8e4cdd111ca4827c829
Author: Liang Zhang <te...@163.com>
AuthorDate: Sun Oct 4 16:42:27 2020 +0800
Remove useless @SneakyThrows (#7697)
---
.../fixture/BinaryStatementRegistryUtil.java | 2 +-
.../encrypt/algorithm/AESEncryptAlgorithm.java | 5 +-
.../encrypt/algorithm/RC4EncryptAlgorithm.java | 2 -
.../DecoratedEncryptColumnsMergedResultTest.java | 4 +-
.../dql/impl/EncryptColumnsMergedResultTest.java | 30 +++++-------
.../keygen/SnowflakeKeyGenerateAlgorithm.java | 2 +-
.../keygen/SnowflakeKeyGenerateAlgorithmTest.java | 10 ++--
.../swapper/RuleSchemaMetaDataYamlSwapperTest.java | 9 ++--
.../governance/core/config/ConfigCenterTest.java | 4 +-
.../listener/ConfigurationListenerManagerTest.java | 4 +-
.../config/listener/SchemaChangedListenerTest.java | 4 +-
.../schema/GovernanceSchemaContextsTest.java | 12 ++---
.../GovernanceTransactionContextsTest.java | 7 +--
.../governance/core/facade/util/FieldUtil.java | 2 +-
.../governance/core/registry/util/FieldUtil.java | 2 +-
.../repository/etcd/EtcdRepositoryTest.java | 12 ++---
.../repository/nacos/NacosRepositoryTest.java | 9 ++--
.../constructor/ShardingSphereYamlConstructor.java | 2 -
.../representer/ShardingSphereYamlRepresenter.java | 2 -
.../YamlRuleConfigurationSwapperEngine.java | 4 +-
.../jdbc/queryresult/MemoryQueryResult.java | 3 +-
.../executor/ExecutorExceptionHandlerTest.java | 4 +-
.../impl/DefaultSQLExecutorCallbackTest.java | 4 +-
.../jdbc/queryresult/MemoryQueryResultTest.java | 8 ++--
.../sql/raw/execute/RawJDBCExecutorTest.java | 16 ++-----
.../infra/route/hook/SPIRoutingHookTest.java | 2 +-
.../cases/assertion/IntegrateTestCasesLoader.java | 4 +-
.../engine/util/IntegrateTestParameters.java | 2 +-
...nceSpringBootPrimaryReplicaReplicationTest.java | 4 +-
.../GovernanceSpringBootRegistryEncryptTest.java | 4 +-
...gBootRegistryPrimaryReplicaReplicationTest.java | 7 +--
.../GovernanceSpringBootRegistryShardingTest.java | 4 +-
.../boot/datasource/DataSourceMapSetterTest.java | 8 ++--
.../opentracing/hook/BaseOpenTracingHookTest.java | 4 +-
.../DatabaseCommunicationEngineFactoryTest.java | 4 +-
.../jdbc/connection/BackendConnectionTest.java | 53 +++++++++-------------
.../jdbc/connection/MethodInvocationTest.java | 4 +-
...StatementMemoryStrictlyFetchSizeSetterTest.java | 5 +-
...StatementMemoryStrictlyFetchSizeSetterTest.java | 5 +-
.../text/admin/BroadcastBackendHandlerTest.java | 3 +-
.../text/admin/DALBackendHandlerFactoryTest.java | 3 +-
.../backend/text/admin/RDLBackendHandlerTest.java | 3 +-
.../admin/ShowDatabasesBackendHandlerTest.java | 4 +-
.../text/admin/ShowTablesBackendHandlerTest.java | 4 +-
.../ShardingCTLExplainBackendHandlerTest.java | 4 +-
.../hint/ShardingCTLHintBackendHandlerTest.java | 4 +-
.../sctl/set/ShardingCTLSetBackendHandlerTest.java | 4 +-
.../TransactionBackendHandlerFactoryTest.java | 5 +-
.../impl/AbstractBootstrapInitializerTest.java | 5 +-
.../impl/GovernanceBootstrapInitializerTest.java | 5 +-
.../impl/StandardBootstrapInitializerTest.java | 4 +-
.../config/yaml/YamlDataSourceParameterMerger.java | 4 +-
.../mysql/auth/MySQLAuthenticationHandlerTest.java | 5 +-
.../PostgreSQLCommandExecuteEngineTest.java | 6 +--
.../scaling/core/datasource/DataSourceFactory.java | 3 +-
.../execute/executor/dumper/DumperFactory.java | 6 +--
.../execute/executor/importer/ImporterFactory.java | 2 +-
.../scaling/core/ScalingJobControllerTest.java | 4 +-
.../executor/channel/DistributionChannelTest.java | 9 ++--
.../importer/AbstractJDBCImporterTest.java | 4 +-
.../executor/importer/AbstractSqlBuilderTest.java | 16 +++----
.../scaling/mysql/MySQLJdbcDumperTest.java | 6 +--
.../scaling/mysql/MySQLPositionManagerTest.java | 4 +-
.../PostgreSQLDataSourceCheckerTest.java | 4 +-
.../postgresql/PostgreSQLJdbcDumperTest.java | 3 +-
.../postgresql/PostgreSQLPositionManagerTest.java | 12 ++---
.../postgresql/PostgreSQLWalDumperTest.java | 4 +-
.../postgresql/wal/LogicalReplicationTest.java | 6 +--
.../core/visitor/ParseTreeVisitorFactory.java | 2 +-
.../sql/common/util/SafeNumberOperationUtils.java | 2 +-
.../manager/AtomikosTransactionManager.java | 4 +-
.../bitronix/manager/BitronixRecoveryResource.java | 5 +-
.../manager/BitronixXATransactionManager.java | 8 ++--
.../manager/BitronixXATransactionManagerTest.java | 10 ++--
.../xa/XAShardingTransactionManager.java | 11 +++--
.../connection/dialect/H2XAConnectionWrapper.java | 7 +--
.../dialect/MariaDBXAConnectionWrapper.java | 5 +-
.../dialect/MySQLXAConnectionWrapper.java | 5 +-
.../dialect/OracleXAConnectionWrapper.java | 3 +-
.../dialect/PostgreSQLXAConnectionWrapper.java | 3 +-
.../manager/NarayanaXATransactionManager.java | 4 +-
.../manager/NarayanaXATransactionManagerTest.java | 11 ++---
.../at/SeataATShardingTransactionManager.java | 7 +--
.../at/SeataATShardingTransactionManagerTest.java | 4 +-
.../base/seata/at/fixture/MockSeataServer.java | 3 +-
85 files changed, 218 insertions(+), 295 deletions(-)
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/fixture/BinaryStatementRegistryUtil.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/fixture/BinaryStatementRegistryUtil.java
index 257cfb6..dbdb097 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/fixture/BinaryStatementRegistryUtil.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/fixture/BinaryStatementRegistryUtil.java
@@ -32,7 +32,7 @@ public final class BinaryStatementRegistryUtil {
/**
* Reset {@code MySQLBinaryStatementRegistry}.
*/
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
public static void reset() {
Field statementIdAssignerField = MySQLBinaryStatementRegistry.class.getDeclaredField("statementIdAssigner");
statementIdAssignerField.setAccessible(true);
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/algorithm/AESEncryptAlgorithm.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/algorithm/AESEncryptAlgorithm.java
index 5556039..0f8e053 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/algorithm/AESEncryptAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/algorithm/AESEncryptAlgorithm.java
@@ -30,6 +30,7 @@ import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
+import java.security.GeneralSecurityException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
@@ -58,7 +59,7 @@ public final class AESEncryptAlgorithm implements EncryptAlgorithm {
return Arrays.copyOf(DigestUtils.sha1(props.getProperty(AES_KEY)), 16);
}
- @SneakyThrows
+ @SneakyThrows(GeneralSecurityException.class)
@Override
public String encrypt(final Object plaintext) {
if (null == plaintext) {
@@ -68,7 +69,7 @@ public final class AESEncryptAlgorithm implements EncryptAlgorithm {
return Base64.encodeBase64String(result);
}
- @SneakyThrows
+ @SneakyThrows(GeneralSecurityException.class)
@Override
public Object decrypt(final String ciphertext) {
if (null == ciphertext) {
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithm.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithm.java
index 2a787db..f2eb14b 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithm.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.encrypt.algorithm;
import lombok.Getter;
import lombok.Setter;
-import lombok.SneakyThrows;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.StringUtils;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
@@ -49,7 +48,6 @@ public final class RC4EncryptAlgorithm implements EncryptAlgorithm {
private Properties props = new Properties();
@Override
- @SneakyThrows
public void init() {
reset();
setKey(StringUtils.getBytesUtf8(props.getProperty(RC4_KEY)));
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-merge/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/impl/DecoratedEncryptColumnsMergedResultTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-merge/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/impl/DecoratedEncryptColumnsMergedResultTest.java
index 54165cd..1a327a8 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-merge/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/impl/DecoratedEncryptColumnsMergedResultTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-merge/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/impl/DecoratedEncryptColumnsMergedResultTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.encrypt.merge.dal.impl;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.encrypt.merge.dal.impl.fixture.TestStatementContext;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.sql.parser.binder.metadata.schema.SchemaMetaData;
@@ -41,8 +40,7 @@ import static org.mockito.Mockito.when;
public final class DecoratedEncryptColumnsMergedResultTest {
@Test
- @SneakyThrows(SQLException.class)
- public void assertNewValidResult() {
+ public void assertNewValidResult() throws SQLException {
TestStatementContext testStatementContext = mock(TestStatementContext.class);
SimpleTableSegment simpleTableSegment = mock(SimpleTableSegment.class);
IdentifierValue identifierValue = mock(IdentifierValue.class);
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-merge/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/impl/EncryptColumnsMergedResultTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-merge/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/impl/EncryptColumnsMergedResultTest.java
index f65bd6b..366c08e 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-merge/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/impl/EncryptColumnsMergedResultTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-merge/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/impl/EncryptColumnsMergedResultTest.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.encrypt.merge.dql.impl;
import com.google.common.collect.Lists;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.encrypt.merge.dql.fixture.EncryptColumnsMergedResultFixture;
import org.apache.shardingsphere.encrypt.merge.dql.fixture.TableAvailableAndSqlStatementContextFixture;
import org.apache.shardingsphere.encrypt.metadata.EncryptColumnMetaData;
@@ -34,6 +33,7 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Calendar;
import java.util.Collections;
@@ -61,10 +61,9 @@ public final class EncryptColumnsMergedResultTest {
private EncryptColumnsMergedResultFixture encryptColumnsMergedResultFixture;
- @SneakyThrows
@Before
public void setUp() {
- Map<String, ColumnMetaData> columns = new HashMap<>();
+ Map<String, ColumnMetaData> columns = new HashMap<>(1, 1);
EncryptColumnMetaData encryptColumnMetaData = new EncryptColumnMetaData("order", 1, "Integer", false, "status", "status", "status");
columns.put("", encryptColumnMetaData);
SimpleTableSegment simpleTableSegment = mock(SimpleTableSegment.class);
@@ -80,9 +79,8 @@ public final class EncryptColumnsMergedResultTest {
encryptColumnsMergedResultFixture = spy(new EncryptColumnsMergedResultFixture(tableAvailableAndSqlStatementContextFixture, schemaMetaData));
}
- @SneakyThrows
@Test
- public void assertHasNextWithEmptyColumnMetaData() {
+ public void assertHasNextWithEmptyColumnMetaData() throws SQLException {
when(schemaMetaData.get(anyString())).thenReturn(tableMetaData);
when(tableMetaData.getColumns()).thenReturn(Collections.emptyMap());
EncryptColumnsMergedResultFixture encryptColumnsMergedResultFixture = spy(new EncryptColumnsMergedResultFixture(tableAvailableAndSqlStatementContextFixture, schemaMetaData));
@@ -90,18 +88,16 @@ public final class EncryptColumnsMergedResultTest {
assertThat(encryptColumnsMergedResultFixture.next(), is(true));
}
- @SneakyThrows
@Test
- public void assertWithoutHasNext() {
+ public void assertWithoutHasNext() throws SQLException {
EncryptColumnsMergedResultFixture encryptColumnsMergedResultFixture = spy(new EncryptColumnsMergedResultFixture(tableAvailableAndSqlStatementContextFixture, schemaMetaData));
when(encryptColumnsMergedResultFixture.nextValue()).thenReturn(false);
assertThat(encryptColumnsMergedResultFixture.next(), is(false));
}
@Test
- @SneakyThrows
- public void assertContainerColumnName() {
- Map<String, ColumnMetaData> columns = new HashMap<>();
+ public void assertContainerColumnName() throws SQLException {
+ Map<String, ColumnMetaData> columns = new HashMap<>(1, 1);
EncryptColumnMetaData encryptColumnMetaData = new EncryptColumnMetaData("order", 1, "Integer", false, "status", "status", "status");
columns.put("", encryptColumnMetaData);
when(schemaMetaData.get(anyString())).thenReturn(tableMetaData);
@@ -112,10 +108,9 @@ public final class EncryptColumnsMergedResultTest {
assertThat(encryptColumnsMergedResultFixture.next(), is(true));
}
- @SneakyThrows
@Test
- public void assertGetValueWithColumnIndex() {
- Map<String, ColumnMetaData> columns = new HashMap<>();
+ public void assertGetValueWithColumnIndex() throws SQLException {
+ Map<String, ColumnMetaData> columns = new HashMap<>(1, 1);
EncryptColumnMetaData encryptColumnMetaData = new EncryptColumnMetaData("order", 1, "Integer", false, "status", "status", "status");
columns.put("key", encryptColumnMetaData);
when(schemaMetaData.get(anyString())).thenReturn(tableMetaData);
@@ -124,22 +119,19 @@ public final class EncryptColumnsMergedResultTest {
assertThat(encryptColumnsMergedResultFixture.getValue(1, String.class), is("key"));
}
- @SneakyThrows
@Test
- public void assertGetValueWithOutColumnIndex() {
+ public void assertGetValueWithOutColumnIndex() throws SQLException {
when(encryptColumnsMergedResultFixture.getOriginalValue(2, String.class)).thenReturn("status");
assertThat(encryptColumnsMergedResultFixture.getValue(2, String.class), is("status"));
}
- @SneakyThrows
@Test(expected = SQLFeatureNotSupportedException.class)
- public void assertGetCalendarValue() {
+ public void assertGetCalendarValue() throws SQLException {
encryptColumnsMergedResultFixture.getCalendarValue(1, String.class, Calendar.getInstance());
}
- @SneakyThrows
@Test(expected = SQLFeatureNotSupportedException.class)
- public void assertGetInputStream() {
+ public void assertGetInputStream() throws SQLException {
encryptColumnsMergedResultFixture.getInputStream(1, "whateverString");
}
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
index d366439..09da258 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
@@ -135,7 +135,7 @@ public final class SnowflakeKeyGenerateAlgorithm implements KeyGenerateAlgorithm
return ((currentMilliseconds - EPOCH) << TIMESTAMP_LEFT_SHIFT_BITS) | (workerId << WORKER_ID_LEFT_SHIFT_BITS) | sequence;
}
- @SneakyThrows
+ @SneakyThrows(InterruptedException.class)
private boolean waitTolerateTimeDifferenceIfNeed(final long currentMilliseconds) {
if (lastMilliseconds <= currentMilliseconds) {
return false;
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithmTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithmTest.java
index 4874fb6..f8119da 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithmTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithmTest.java
@@ -161,14 +161,14 @@ public final class SnowflakeKeyGenerateAlgorithmTest {
assertThat(actual, is(expected));
}
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
private void setSequence(final SnowflakeKeyGenerateAlgorithm keyGenerateAlgorithm, final Number value) {
Field sequence = SnowflakeKeyGenerateAlgorithm.class.getDeclaredField("sequence");
sequence.setAccessible(true);
sequence.set(keyGenerateAlgorithm, value);
}
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
private void setLastMilliseconds(final SnowflakeKeyGenerateAlgorithm keyGenerateAlgorithm, final Number value) {
Field lastMilliseconds = SnowflakeKeyGenerateAlgorithm.class.getDeclaredField("lastMilliseconds");
lastMilliseconds.setAccessible(true);
@@ -216,8 +216,7 @@ public final class SnowflakeKeyGenerateAlgorithmTest {
}
@Test
- @SneakyThrows
- public void assertSetWorkerIdSuccess() {
+ public void assertSetWorkerIdSuccess() throws NoSuchFieldException, IllegalAccessException {
SnowflakeKeyGenerateAlgorithm keyGenerateAlgorithm = new SnowflakeKeyGenerateAlgorithm();
Properties props = new Properties();
props.setProperty("worker-id", String.valueOf(1L));
@@ -229,8 +228,7 @@ public final class SnowflakeKeyGenerateAlgorithmTest {
}
@Test
- @SneakyThrows
- public void assertSetMaxTolerateTimeDifferenceMilliseconds() {
+ public void assertSetMaxTolerateTimeDifferenceMilliseconds() throws NoSuchFieldException, IllegalAccessException {
SnowflakeKeyGenerateAlgorithm keyGenerateAlgorithm = new SnowflakeKeyGenerateAlgorithm();
Properties props = new Properties();
props.setProperty("max-tolerate-time-difference-milliseconds", String.valueOf(1));
diff --git a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-common/src/test/java/org/apache/shardingsphere/governance/core/yaml/swapper/RuleSchemaMetaDataYamlSwapperTest.java b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-common/src/test/java/org/apache/shardingsphere/governance/core/yaml/swapper/RuleSchemaMetaDataYamlSwapperTest.java
index 29c0d5b..535e10a 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-common/src/test/java/org/apache/shardingsphere/governance/core/yaml/swapper/RuleSchemaMetaDataYamlSwapperTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-common/src/test/java/org/apache/shardingsphere/governance/core/yaml/swapper/RuleSchemaMetaDataYamlSwapperTest.java
@@ -23,9 +23,10 @@ import org.apache.shardingsphere.infra.metadata.schema.RuleSchemaMetaData;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.junit.Test;
+import java.io.IOException;
+import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
-import java.util.Arrays;
import java.util.Collections;
import java.util.stream.Collectors;
@@ -48,7 +49,7 @@ public final class RuleSchemaMetaDataYamlSwapperTest {
assertThat(yamlRuleSchemaMetaData.getConfiguredSchemaMetaData().getTables().get("t_order").getIndexes().keySet(), is(Collections.singleton("primary")));
assertThat(yamlRuleSchemaMetaData.getConfiguredSchemaMetaData().getTables().get("t_order").getColumns().keySet(), is(Collections.singleton("id")));
assertThat(yamlRuleSchemaMetaData.getUnconfiguredSchemaMetaDataMap().keySet(), is(Collections.singleton("ds_0")));
- assertThat(yamlRuleSchemaMetaData.getUnconfiguredSchemaMetaDataMap().get("ds_0"), is(Arrays.asList("t_user")));
+ assertThat(yamlRuleSchemaMetaData.getUnconfiguredSchemaMetaDataMap().get("ds_0"), is(Collections.singletonList("t_user")));
}
@Test
@@ -63,10 +64,10 @@ public final class RuleSchemaMetaDataYamlSwapperTest {
assertThat(ruleSchemaMetaData.getConfiguredSchemaMetaData().getAllColumnNames("t_order").size(), is(1));
assertThat(ruleSchemaMetaData.getConfiguredSchemaMetaData().get("t_order").getColumns().keySet(), is(Collections.singleton("id")));
assertThat(ruleSchemaMetaData.getUnconfiguredSchemaMetaDataMap().keySet(), is(Collections.singleton("ds_0")));
- assertThat(ruleSchemaMetaData.getUnconfiguredSchemaMetaDataMap().get("ds_0"), is(Arrays.asList("t_user")));
+ assertThat(ruleSchemaMetaData.getUnconfiguredSchemaMetaDataMap().get("ds_0"), is(Collections.singletonList("t_user")));
}
- @SneakyThrows
+ @SneakyThrows({URISyntaxException.class, IOException.class})
private String readYAML(final String yamlFile) {
return Files.readAllLines(Paths.get(ClassLoader.getSystemResource(yamlFile).toURI()))
.stream().filter(each -> !each.startsWith("#")).map(each -> each + System.lineSeparator()).collect(Collectors.joining());
diff --git a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/ConfigCenterTest.java b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/ConfigCenterTest.java
index 6e43040..f959c2f 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/ConfigCenterTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/ConfigCenterTest.java
@@ -48,6 +48,8 @@ import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import javax.sql.DataSource;
+import java.io.IOException;
+import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
@@ -431,7 +433,7 @@ public final class ConfigCenterTest {
assertThat(actual.getProps().get("connectionInitSqls"), is(expected.getProps().get("connectionInitSqls")));
}
- @SneakyThrows
+ @SneakyThrows({IOException.class, URISyntaxException.class})
private String readYAML(final String yamlFile) {
return Files.readAllLines(Paths.get(ClassLoader.getSystemResource(yamlFile).toURI()))
.stream().filter(each -> !each.startsWith("#")).map(each -> each + System.lineSeparator()).collect(Collectors.joining());
diff --git a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/listener/ConfigurationListenerManagerTest.java b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/listener/ConfigurationListenerManagerTest.java
index 7c8dc3c..03566ef 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/listener/ConfigurationListenerManagerTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/listener/ConfigurationListenerManagerTest.java
@@ -55,8 +55,8 @@ public final class ConfigurationListenerManagerTest {
verify(propertiesChangedListener).watch(ChangedType.UPDATED);
verify(authenticationChangedListener).watch(ChangedType.UPDATED);
}
-
- @SneakyThrows
+
+ @SneakyThrows(ReflectiveOperationException.class)
private static void setField(final Object target, final String fieldName, final Object fieldValue) {
Field field = target.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
diff --git a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/listener/SchemaChangedListenerTest.java b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/listener/SchemaChangedListenerTest.java
index 53f8f39..8cfaa75 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/listener/SchemaChangedListenerTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/listener/SchemaChangedListenerTest.java
@@ -38,6 +38,8 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import java.io.IOException;
+import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
@@ -258,7 +260,7 @@ public final class SchemaChangedListenerTest {
assertTrue(((MetaDataChangedEvent) actual.get()).getRuleSchemaMetaData().getConfiguredSchemaMetaData().getAllTableNames().contains("t_order"));
}
- @SneakyThrows
+ @SneakyThrows({IOException.class, URISyntaxException.class})
private String readYAML(final String yamlFile) {
return Files.readAllLines(Paths.get(ClassLoader.getSystemResource(yamlFile).toURI())).stream().map(each -> each + System.lineSeparator()).collect(Collectors.joining());
}
diff --git a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/test/java/org/apache/shardingsphere/governance/context/schema/GovernanceSchemaContextsTest.java b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/test/java/org/apache/shardingsphere/governance/context/schema/GovernanceSchemaContextsTest.java
index 7a42e10..854c483 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/test/java/org/apache/shardingsphere/governance/context/schema/GovernanceSchemaContextsTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/test/java/org/apache/shardingsphere/governance/context/schema/GovernanceSchemaContextsTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.governance.context.schema;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.governance.core.config.ConfigCenter;
import org.apache.shardingsphere.governance.core.event.model.auth.AuthenticationChangedEvent;
import org.apache.shardingsphere.governance.core.event.model.datasource.DataSourceChangedEvent;
@@ -52,6 +51,7 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import java.sql.SQLException;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -110,7 +110,6 @@ public final class GovernanceSchemaContextsTest {
new StandardSchemaContexts(createSchemas(), mock(ShardingSphereSQLParserEngine.class), mock(ExecutorKernel.class), authentication, props, databaseType), governanceFacade);
}
- @SneakyThrows
private Map<String, ShardingSphereSchema> createSchemas() {
when(schema.getName()).thenReturn("schema");
when(schema.getMetaData()).thenReturn(mock(ShardingSphereMetaData.class));
@@ -149,8 +148,7 @@ public final class GovernanceSchemaContextsTest {
}
@Test
- @SneakyThrows
- public void assertSchemaAdd() {
+ public void assertSchemaAdd() throws SQLException {
SchemaAddedEvent event = new SchemaAddedEvent("schema_add", new HashMap<>(), new LinkedList<>());
when(configCenter.loadDataSourceConfigurations("schema_add")).thenReturn(getDataSourceConfigurations());
governanceSchemaContexts.renew(event);
@@ -207,8 +205,7 @@ public final class GovernanceSchemaContextsTest {
}
@Test
- @SneakyThrows
- public void assertRuleConfigurationsChanged() {
+ public void assertRuleConfigurationsChanged() throws SQLException {
assertThat(governanceSchemaContexts.getSchemas().get("schema"), is(schema));
RuleConfigurationsChangedEvent event = new RuleConfigurationsChangedEvent("schema", new LinkedList<>());
governanceSchemaContexts.renew(event);
@@ -223,8 +220,7 @@ public final class GovernanceSchemaContextsTest {
}
@Test
- @SneakyThrows
- public void assertDataSourceChanged() {
+ public void assertDataSourceChanged() throws SQLException {
DataSourceChangedEvent event = new DataSourceChangedEvent("schema", getChangedDataSourceConfigurations());
governanceSchemaContexts.renew(event);
assertTrue(governanceSchemaContexts.getSchemas().get("schema").getDataSources().containsKey("ds_2"));
diff --git a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/test/java/org/apache/shardingsphere/governance/context/transaction/GovernanceTransactionContextsTest.java b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/test/java/org/apache/shardingsphere/governance/context/transaction/GovernanceTransactionContextsTest.java
index 7955614..970264a 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/test/java/org/apache/shardingsphere/governance/context/transaction/GovernanceTransactionContextsTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/test/java/org/apache/shardingsphere/governance/context/transaction/GovernanceTransactionContextsTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.governance.context.transaction;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.governance.core.event.model.datasource.DataSourceChangeCompletedEvent;
import org.apache.shardingsphere.transaction.ShardingTransactionManagerEngine;
import org.apache.shardingsphere.transaction.context.TransactionContexts;
@@ -61,16 +60,14 @@ public final class GovernanceTransactionContextsTest {
}
@Test
- @SneakyThrows
- public void assertClose() {
+ public void assertClose() throws Exception {
GovernanceTransactionContexts actual = new GovernanceTransactionContexts(transactionContexts);
actual.close();
verify(transactionContexts).close();
}
@Test
- @SneakyThrows
- public void assertRenew() {
+ public void assertRenew() throws Exception {
when(event.getSchemaName()).thenReturn("name");
when(transactionContexts.getEngines()).thenReturn(engineMap);
when(engineMap.remove(eq("name"))).thenReturn(engine);
diff --git a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-facade/src/test/java/org/apache/shardingsphere/governance/core/facade/util/FieldUtil.java b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-facade/src/test/java/org/apache/shardingsphere/governance/core/facade/util/FieldUtil.java
index d5830f1..fec9223 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-facade/src/test/java/org/apache/shardingsphere/governance/core/facade/util/FieldUtil.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-facade/src/test/java/org/apache/shardingsphere/governance/core/facade/util/FieldUtil.java
@@ -36,7 +36,7 @@ public final class FieldUtil {
* @param fieldName field name to be settled
* @param fieldValue field value to be settled
*/
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
public static void setField(final Object target, final String fieldName, final Object fieldValue) {
Field field = target.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
diff --git a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-registry/src/test/java/org/apache/shardingsphere/governance/core/registry/util/FieldUtil.java b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-registry/src/test/java/org/apache/shardingsphere/governance/core/registry/util/FieldUtil.java
index f8c6935..f1eb7ab 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-registry/src/test/java/org/apache/shardingsphere/governance/core/registry/util/FieldUtil.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-registry/src/test/java/org/apache/shardingsphere/governance/core/registry/util/FieldUtil.java
@@ -36,7 +36,7 @@ public final class FieldUtil {
* @param fieldName field name to be settled
* @param fieldValue field value to be settled
*/
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
public static void setField(final Object target, final String fieldName, final Object fieldValue) {
Field field = target.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
diff --git a/shardingsphere-governance/shardingsphere-governance-repository/shardingsphere-governance-repository-provider/shardingsphere-governance-repository-etcd/src/test/java/org/apache/shardingsphere/governance/repository/etcd/EtcdRepositoryTest.java b/shardingsphere-governance/shardingsphere-governance-repository/shardingsphere-governance-repository-provider/shardingsphere-governance-repository-etcd/src/test/java/org/apache/shardingsphere/governance/repository/etcd/EtcdRepositoryTest.java
index 407fbc6..a5b7895 100644
--- a/shardingsphere-governance/shardingsphere-governance-repository/shardingsphere-governance-repository-provider/shardingsphere-governance-repository-etcd/src/test/java/org/apache/shardingsphere/governance/repository/etcd/EtcdRepositoryTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-repository/shardingsphere-governance-repository-provider/shardingsphere-governance-repository-etcd/src/test/java/org/apache/shardingsphere/governance/repository/etcd/EtcdRepositoryTest.java
@@ -228,8 +228,7 @@ public final class EtcdRepositoryTest {
}
@Test
- @SneakyThrows
- public void assertGetKeyWhenThrowInterruptedException() {
+ public void assertGetKeyWhenThrowInterruptedException() throws ExecutionException, InterruptedException {
doThrow(InterruptedException.class).when(getFuture).get();
try {
repository.get("key");
@@ -241,8 +240,7 @@ public final class EtcdRepositoryTest {
}
@Test
- @SneakyThrows
- public void assertGetKeyWhenThrowExecutionException() {
+ public void assertGetKeyWhenThrowExecutionException() throws ExecutionException, InterruptedException {
doThrow(ExecutionException.class).when(getFuture).get();
try {
repository.get("key");
@@ -254,8 +252,7 @@ public final class EtcdRepositoryTest {
}
@Test
- @SneakyThrows
- public void assertGetChildrenKeysWhenThrowInterruptedException() {
+ public void assertGetChildrenKeysWhenThrowInterruptedException() throws ExecutionException, InterruptedException {
doThrow(InterruptedException.class).when(getFuture).get();
try {
repository.getChildrenKeys("/key/key1");
@@ -267,8 +264,7 @@ public final class EtcdRepositoryTest {
}
@Test
- @SneakyThrows
- public void assertGetChildrenKeysWhenThrowExecutionException() {
+ public void assertGetChildrenKeysWhenThrowExecutionException() throws ExecutionException, InterruptedException {
doThrow(ExecutionException.class).when(getFuture).get();
try {
repository.getChildrenKeys("/key/key1");
diff --git a/shardingsphere-governance/shardingsphere-governance-repository/shardingsphere-governance-repository-provider/shardingsphere-governance-repository-nacos/src/test/java/org/apache/shardingsphere/governance/repository/nacos/NacosRepositoryTest.java b/shardingsphere-governance/shardingsphere-governance-repository/shardingsphere-governance-repository-provider/shardingsphere-governance-repository-nacos/src/test/java/org/apache/shardingsphere/governance/repository/nacos/NacosReposito [...]
index 4c4c9b0..dcfc3dc 100644
--- a/shardingsphere-governance/shardingsphere-governance-repository/shardingsphere-governance-repository-provider/shardingsphere-governance-repository-nacos/src/test/java/org/apache/shardingsphere/governance/repository/nacos/NacosRepositoryTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-repository/shardingsphere-governance-repository-provider/shardingsphere-governance-repository-nacos/src/test/java/org/apache/shardingsphere/governance/repository/nacos/NacosRepositoryTest.java
@@ -144,18 +144,16 @@ public final class NacosRepositoryTest {
verify(configService).removeConfig("sharding.test", group);
}
- @SneakyThrows
@Test
- public void assertDeleteWhenThrowException() {
+ public void assertDeleteWhenThrowException() throws NacosException {
when(configService.getConfig(eq("sharding.test"), eq(group), anyLong())).thenReturn("value");
doThrow(NacosException.class).when(configService).removeConfig(eq("sharding.test"), eq(group));
REPOSITORY.delete("/sharding/test");
assertNotNull(REPOSITORY.get("/sharding/test"));
}
- @SneakyThrows
@Test
- public void assertWatchWhenThrowException() {
+ public void assertWatchWhenThrowException() throws NacosException {
ChangedType[] actualType = {null};
doThrow(NacosException.class).when(configService).addListener(anyString(), anyString(), any(Listener.class));
DataChangedEventListener listener = dataChangedEvent -> actualType[0] = dataChangedEvent.getChangedType();
@@ -164,8 +162,7 @@ public final class NacosRepositoryTest {
}
@Test
- @SneakyThrows
- public void assertPersistWhenThrowException() {
+ public void assertPersistWhenThrowException() throws NacosException {
String value = "value";
doThrow(NacosException.class).when(configService).publishConfig(eq("sharding.test"), eq(group), eq(value));
REPOSITORY.persist("/sharding/test", value);
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/engine/constructor/ShardingSphereYamlConstructor.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/engine/constructor/ShardingSphereYamlConstructor.java
index 764de03..01f661d 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/engine/constructor/ShardingSphereYamlConstructor.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/engine/constructor/ShardingSphereYamlConstructor.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.infra.yaml.engine.constructor;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
import org.yaml.snakeyaml.TypeDescription;
@@ -39,7 +38,6 @@ public final class ShardingSphereYamlConstructor extends Constructor {
private final Map<Class, Construct> typeConstructs = new HashMap<>();
- @SneakyThrows
public ShardingSphereYamlConstructor(final Class<?> rootClass) {
super(rootClass);
ShardingSphereServiceLoader.newServiceInstances(ShardingSphereYamlConstruct.class).forEach(each -> typeConstructs.put(each.getType(), each));
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/engine/representer/ShardingSphereYamlRepresenter.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/engine/representer/ShardingSphereYamlRepresenter.java
index 1d7934a..d1b381b 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/engine/representer/ShardingSphereYamlRepresenter.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/engine/representer/ShardingSphereYamlRepresenter.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.infra.yaml.engine.representer;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.yaml.engine.representer.processor.DefaultYamlTupleProcessor;
import org.apache.shardingsphere.infra.yaml.engine.representer.processor.ShardingSphereYamlTupleProcessor;
@@ -36,7 +35,6 @@ public final class ShardingSphereYamlRepresenter extends Representer {
ShardingSphereServiceLoader.register(ShardingSphereYamlTupleProcessor.class);
}
- @SneakyThrows
public ShardingSphereYamlRepresenter() {
YamlRuleConfigurationSwapperEngine.getYamlShortcuts().forEach((key, value) -> addClassTag(value, new Tag(key)));
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/YamlRuleConfigurationSwapperEngine.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/YamlRuleConfigurationSwapperEngine.java
index 156d17f..be45a5e 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/YamlRuleConfigurationSwapperEngine.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/YamlRuleConfigurationSwapperEngine.java
@@ -18,9 +18,9 @@
package org.apache.shardingsphere.infra.yaml.swapper;
import lombok.SneakyThrows;
+import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.order.OrderedSPIRegistry;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration;
import java.lang.reflect.ParameterizedType;
@@ -87,7 +87,7 @@ public final class YamlRuleConfigurationSwapperEngine {
*
* @return YAML shortcuts
*/
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
public static Map<String, Class<?>> getYamlShortcuts() {
Map<String, Class<?>> result = new HashMap<>();
for (YamlRuleConfigurationSwapper each : ShardingSphereServiceLoader.newServiceInstances(YamlRuleConfigurationSwapper.class)) {
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/jdbc/queryresult/MemoryQueryResult.java b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/jdbc/queryresult/MemoryQueryResult.java
index a58acf0..0c478e0 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/jdbc/queryresult/MemoryQueryResult.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/jdbc/queryresult/MemoryQueryResult.java
@@ -22,6 +22,7 @@ import org.apache.shardingsphere.infra.executor.sql.QueryResult;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectOutputStream;
import java.math.BigDecimal;
@@ -144,7 +145,7 @@ public final class MemoryQueryResult implements QueryResult {
return getInputStream(currentRow.get(columnIndex - 1));
}
- @SneakyThrows
+ @SneakyThrows(IOException.class)
private InputStream getInputStream(final Object value) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/jdbc/executor/ExecutorExceptionHandlerTest.java b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/jdbc/executor/ExecutorExceptionHandlerTest.java
index 47dcb3d..fd0d73a 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/jdbc/executor/ExecutorExceptionHandlerTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/jdbc/executor/ExecutorExceptionHandlerTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.infra.executor.sql.jdbc.executor;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.executor.ExecutorExceptionHandler;
import org.junit.After;
import org.junit.Test;
@@ -31,8 +30,7 @@ import static org.junit.Assert.assertTrue;
public final class ExecutorExceptionHandlerTest {
@After
- @SneakyThrows
- public void tearDown() {
+ public void tearDown() throws NoSuchFieldException, IllegalAccessException {
Field field = ExecutorExceptionHandler.class.getDeclaredField("IS_EXCEPTION_THROWN");
field.setAccessible(true);
((ThreadLocal) field.get(ExecutorExceptionHandler.class)).remove();
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/jdbc/executor/impl/DefaultSQLExecutorCallbackTest.java b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/jdbc/executor/impl/DefaultSQLExecutorCallbackTest.java
index 1c3814c..e355c02 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/jdbc/executor/impl/DefaultSQLExecutorCallbackTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/jdbc/executor/impl/DefaultSQLExecutorCallbackTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.infra.executor.sql.jdbc.executor.impl;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.database.metadata.DataSourceMetaData;
import org.apache.shardingsphere.infra.database.type.DatabaseTypes;
import org.apache.shardingsphere.infra.executor.sql.ConnectionMode;
@@ -71,8 +70,7 @@ public final class DefaultSQLExecutorCallbackTest {
@SuppressWarnings("unchecked")
@Test
- @SneakyThrows(ReflectiveOperationException.class)
- public void execute() throws SQLException {
+ public void assertExecute() throws SQLException, NoSuchFieldException, IllegalAccessException {
SQLExecutorCallback<?> sqlExecutorCallback = new DefaultSQLExecutorCallback<Integer>(DatabaseTypes.getActualDatabaseType("MySQL"), true) {
@Override
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/jdbc/queryresult/MemoryQueryResultTest.java b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/jdbc/queryresult/MemoryQueryResultTest.java
index afe2d74..8cfe7d1 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/jdbc/queryresult/MemoryQueryResultTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/jdbc/queryresult/MemoryQueryResultTest.java
@@ -17,13 +17,13 @@
package org.apache.shardingsphere.infra.executor.sql.jdbc.queryresult;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.queryresult.MemoryQueryResult;
import org.hamcrest.core.Is;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectOutputStream;
import java.math.BigDecimal;
@@ -336,16 +336,14 @@ public final class MemoryQueryResultTest {
}
@Test
- @SneakyThrows
- public void assertGetInputStream() {
+ public void assertGetInputStream() throws SQLException, IOException {
MemoryQueryResult queryResult = new MemoryQueryResult(getResultSet());
queryResult.next();
InputStream inputStream = queryResult.getInputStream(1, "Unicode");
assertThat(inputStream.read(), is(getInputStream(1).read()));
}
- @SneakyThrows
- private InputStream getInputStream(final Object value) {
+ private InputStream getInputStream(final Object value) throws IOException {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
objectOutputStream.writeObject(value);
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/raw/execute/RawJDBCExecutorTest.java b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/raw/execute/RawJDBCExecutorTest.java
index 5814b5d..053df87 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/raw/execute/RawJDBCExecutorTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/raw/execute/RawJDBCExecutorTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.infra.executor.sql.raw.execute;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.executor.kernel.ExecutorKernel;
import org.apache.shardingsphere.infra.executor.sql.QueryResult;
import org.apache.shardingsphere.infra.executor.sql.raw.execute.result.query.ExecuteQueryResult;
@@ -42,16 +41,14 @@ import static org.mockito.Mockito.when;
public final class RawJDBCExecutorTest {
@Test
- @SneakyThrows(SQLException.class)
- public void assertExecuteForResultEmpty() {
+ public void assertExecuteForResultEmpty() throws SQLException {
ExecutorKernel kernel = mock(ExecutorKernel.class);
RawJDBCExecutor executor = new RawJDBCExecutor(kernel, true);
assertFalse(executor.execute(null, null));
}
@Test
- @SneakyThrows(SQLException.class)
- public void assertExecuteForExecuteQueryResult() {
+ public void assertExecuteForExecuteQueryResult() throws SQLException {
ExecutorKernel kernel = mock(ExecutorKernel.class);
when(kernel.execute(any(), any(), any(), anyBoolean())).thenReturn(Collections.singletonList(new ExecuteQueryResult(null, null)));
RawJDBCExecutor executor = new RawJDBCExecutor(kernel, true);
@@ -59,8 +56,7 @@ public final class RawJDBCExecutorTest {
}
@Test
- @SneakyThrows(SQLException.class)
- public void assertExecuteQueryForExecuteQueryResult() {
+ public void assertExecuteQueryForExecuteQueryResult() throws SQLException {
ExecutorKernel kernel = mock(ExecutorKernel.class);
ExecuteQueryResult executeQueryResult = mock(ExecuteQueryResult.class);
QueryResult queryResult = mock(QueryResult.class);
@@ -72,8 +68,7 @@ public final class RawJDBCExecutorTest {
}
@Test
- @SneakyThrows(SQLException.class)
- public void assertExecuteUpdate() {
+ public void assertExecuteUpdate() throws SQLException {
ExecutorKernel kernel = mock(ExecutorKernel.class);
ExecuteUpdateResult executeUpdateResult1 = new ExecuteUpdateResult(1, 2);
ExecuteUpdateResult executeUpdateResult2 = new ExecuteUpdateResult(3, 4);
@@ -83,8 +78,7 @@ public final class RawJDBCExecutorTest {
}
@Test
- @SneakyThrows(SQLException.class)
- public void assertExecuteNotThrownSQLException() {
+ public void assertExecuteNotThrownSQLException() throws SQLException {
ExecutorKernel kernel = mock(ExecutorKernel.class);
when(kernel.execute(any(), any(), any(), anyBoolean())).thenThrow(new SQLException("TestSQLException"));
RawJDBCExecutor rawJDBCExecutor = new RawJDBCExecutor(kernel, false);
diff --git a/shardingsphere-infra/shardingsphere-infra-route/src/test/java/org/apache/shardingsphere/infra/route/hook/SPIRoutingHookTest.java b/shardingsphere-infra/shardingsphere-infra-route/src/test/java/org/apache/shardingsphere/infra/route/hook/SPIRoutingHookTest.java
index fb631a0..ee9160e 100644
--- a/shardingsphere-infra/shardingsphere-infra-route/src/test/java/org/apache/shardingsphere/infra/route/hook/SPIRoutingHookTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-route/src/test/java/org/apache/shardingsphere/infra/route/hook/SPIRoutingHookTest.java
@@ -74,7 +74,7 @@ public final class SPIRoutingHookTest {
}
@SuppressWarnings("unchecked")
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
private RoutingHook getFixtureHook() {
Field routingHooksField = SPIRoutingHook.class.getDeclaredField("routingHooks");
routingHooksField.setAccessible(true);
diff --git a/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/cases/assertion/IntegrateTestCasesLoader.java b/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/cases/assertion/IntegrateTestCasesLoader.java
index e051e8b..618c437 100644
--- a/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/cases/assertion/IntegrateTestCasesLoader.java
+++ b/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/cases/assertion/IntegrateTestCasesLoader.java
@@ -69,13 +69,13 @@ public final class IntegrateTestCasesLoader {
* @param sqlType SQL type
* @return integrate test cases
*/
- @SneakyThrows
public List<? extends IntegrateTestCase> getTestCases(final SQLType sqlType) {
integrateTestCases.putIfAbsent(sqlType, loadIntegrateTestCases(sqlType));
return integrateTestCases.get(sqlType);
}
- private List<? extends IntegrateTestCase> loadIntegrateTestCases(final SQLType sqlType) throws IOException, URISyntaxException, JAXBException {
+ @SneakyThrows({IOException.class, URISyntaxException.class, JAXBException.class})
+ private List<? extends IntegrateTestCase> loadIntegrateTestCases(final SQLType sqlType) {
URL url = IntegrateTestCasesLoader.class.getClassLoader().getResource("integrate/cases/");
Preconditions.checkNotNull(url, "Cannot found integrate test cases.");
return loadIntegrateTestCases(url, sqlType);
diff --git a/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/engine/util/IntegrateTestParameters.java b/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/engine/util/IntegrateTestParameters.java
index f0a88a2..c811c9f 100644
--- a/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/engine/util/IntegrateTestParameters.java
+++ b/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/engine/util/IntegrateTestParameters.java
@@ -161,7 +161,7 @@ public final class IntegrateTestParameters {
log.info(summary);
}
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
private static long calculateRunnableTestAnnotation() {
long result = 0;
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootPrimaryReplicaReplicationTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSprin [...]
index 4ca2e38..483e11f 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootPrimaryReplicaReplicationTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootPrimaryReplicaReplicationTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.spring.boot.governance.type;
-import lombok.SneakyThrows;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.shardingsphere.driver.governance.internal.datasource.GovernanceShardingSphereDataSource;
import org.apache.shardingsphere.infra.context.schema.SchemaContexts;
@@ -57,8 +56,7 @@ public class GovernanceSpringBootPrimaryReplicaReplicationTest {
}
@Test
- @SneakyThrows(ReflectiveOperationException.class)
- public void assertDataSource() {
+ public void assertDataSource() throws NoSuchFieldException, IllegalAccessException {
assertTrue(dataSource instanceof GovernanceShardingSphereDataSource);
Field field = GovernanceShardingSphereDataSource.class.getDeclaredField("schemaContexts");
field.setAccessible(true);
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryEncryptTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegis [...]
index ac7ce57..fdf94dc 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryEncryptTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryEncryptTest.java
@@ -36,7 +36,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
import javax.sql.DataSource;
+import java.io.IOException;
import java.lang.reflect.Field;
+import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.stream.Collectors;
@@ -87,7 +89,7 @@ public class GovernanceSpringBootRegistryEncryptTest {
assertThat(encryptAlgorithmConfig.getType(), is("AES"));
}
- @SneakyThrows
+ @SneakyThrows({IOException.class, URISyntaxException.class})
private static String readYAML(final String yamlFile) {
return Files.readAllLines(Paths.get(ClassLoader.getSystemResource(yamlFile).toURI())).stream().map(each -> each + System.lineSeparator()).collect(Collectors.joining());
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryPrimaryReplicaReplicationTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/Governa [...]
index bcf8dd7..abe3736 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryPrimaryReplicaReplicationTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryPrimaryReplicaReplicationTest.java
@@ -33,7 +33,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
import javax.sql.DataSource;
+import java.io.IOException;
import java.lang.reflect.Field;
+import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.stream.Collectors;
@@ -66,8 +68,7 @@ public class GovernanceSpringBootRegistryPrimaryReplicaReplicationTest {
}
@Test
- @SneakyThrows(ReflectiveOperationException.class)
- public void assertWithPrimaryReplicaReplicationDataSource() {
+ public void assertWithPrimaryReplicaReplicationDataSource() throws NoSuchFieldException, IllegalAccessException {
assertTrue(dataSource instanceof GovernanceShardingSphereDataSource);
Field field = GovernanceShardingSphereDataSource.class.getDeclaredField("schemaContexts");
field.setAccessible(true);
@@ -78,7 +79,7 @@ public class GovernanceSpringBootRegistryPrimaryReplicaReplicationTest {
}
}
- @SneakyThrows
+ @SneakyThrows({URISyntaxException.class, IOException.class})
private static String readYAML(final String yamlFile) {
return Files.readAllLines(Paths.get(ClassLoader.getSystemResource(yamlFile).toURI())).stream().map(each -> each + System.lineSeparator()).collect(Collectors.joining());
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryShardingTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegi [...]
index c5b98e3..aa06b42 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryShardingTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryShardingTest.java
@@ -38,7 +38,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
import javax.sql.DataSource;
+import java.io.IOException;
import java.lang.reflect.Field;
+import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.stream.Collectors;
@@ -168,7 +170,7 @@ public class GovernanceSpringBootRegistryShardingTest {
return (T) field.get(target);
}
- @SneakyThrows
+ @SneakyThrows({URISyntaxException.class, IOException.class})
private static String readYAML(final String yamlFile) {
return Files.readAllLines(Paths.get(ClassLoader.getSystemResource(yamlFile).toURI())).stream().map(each -> each + System.lineSeparator()).collect(Collectors.joining());
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/test/java/org/apache/shardingsphere/spring/boot/datasource/DataSourceMapSetterTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/test/java/org/apache/shardingsphere/spring/boot/datasource/DataSourceMapSetterTest.java
index eb8c105..d9c444b 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/test/java/org/apache/shardingsphere/spring/boot/datasource/DataSourceMapSetterTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/test/java/org/apache/shardingsphere/spring/boot/datasource/DataSourceMapSetterTest.java
@@ -17,12 +17,12 @@
package org.apache.shardingsphere.spring.boot.datasource;
-import lombok.SneakyThrows;
import org.junit.Test;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.mock.env.MockEnvironment;
import javax.sql.DataSource;
+import java.sql.SQLException;
import java.util.Map;
import static org.hamcrest.CoreMatchers.is;
@@ -30,9 +30,8 @@ import static org.junit.Assert.assertThat;
public final class DataSourceMapSetterTest {
- @SneakyThrows
@Test
- public void assetMergedAll() {
+ public void assetMergedAll() throws SQLException {
MockEnvironment mockEnvironment = new MockEnvironment();
mockEnvironment.setProperty("spring.shardingsphere.datasource.names", "ds0,ds1");
mockEnvironment.setProperty("spring.shardingsphere.datasource.common.type", "org.apache.commons.dbcp2.BasicDataSource");
@@ -50,9 +49,8 @@ public final class DataSourceMapSetterTest {
assertThat(dataSourceMap.get("ds1").getConnection().getMetaData().getURL(), is("jdbc:h2:mem:ds"));
}
- @SneakyThrows
@Test
- public void assetMergedReplaceAndAdd() {
+ public void assetMergedReplaceAndAdd() throws SQLException {
MockEnvironment mockEnvironment = new MockEnvironment();
mockEnvironment.setProperty("spring.shardingsphere.datasource.names", "ds0,ds1");
mockEnvironment.setProperty("spring.shardingsphere.datasource.common.type", "org.apache.commons.dbcp2.BasicDataSource");
diff --git a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/hook/BaseOpenTracingHookTest.java b/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/hook/BaseOpenTracingHookTest.java
index b57f1be..a03e32d 100644
--- a/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/hook/BaseOpenTracingHookTest.java
+++ b/shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/hook/BaseOpenTracingHookTest.java
@@ -23,7 +23,6 @@ import io.opentracing.mock.MockTracer;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import io.opentracing.util.ThreadLocalActiveSpanSource;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.tracing.opentracing.OpenTracingTracer;
import org.apache.shardingsphere.tracing.opentracing.constant.ShardingErrorLogTags;
import org.junit.AfterClass;
@@ -47,8 +46,7 @@ public abstract class BaseOpenTracingHookTest {
}
@AfterClass
- @SneakyThrows(ReflectiveOperationException.class)
- public static void releaseTracer() {
+ public static void releaseTracer() throws NoSuchFieldException, IllegalAccessException {
Field field = GlobalTracer.class.getDeclaredField("tracer");
field.setAccessible(true);
field.set(GlobalTracer.class, NoopTracerFactory.create());
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/DatabaseCommunicationEngineFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/DatabaseCommunicationEngineFactoryTest.java
index 32a0c13..23ed856 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/DatabaseCommunicationEngineFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/DatabaseCommunicationEngineFactoryTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.proxy.backend.communication.jdbc;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.auth.Authentication;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.schema.impl.StandardSchemaContexts;
@@ -48,8 +47,7 @@ import static org.mockito.Mockito.when;
public final class DatabaseCommunicationEngineFactoryTest {
@Before
- @SneakyThrows(ReflectiveOperationException.class)
- public void setUp() {
+ public void setUp() throws IllegalAccessException, NoSuchFieldException {
Field schemaContexts = ProxyContext.getInstance().getClass().getDeclaredField("schemaContexts");
schemaContexts.setAccessible(true);
schemaContexts.set(ProxyContext.getInstance(), new StandardSchemaContexts(getSchemas(),
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnectionTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnectionTest.java
index ca5ffb5..e332c4d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnectionTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnectionTest.java
@@ -42,6 +42,7 @@ import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.sql.Connection;
import java.sql.ResultSet;
@@ -198,7 +199,7 @@ public final class BackendConnectionTest {
thread2.join();
}
- @SneakyThrows
+ @SneakyThrows(SQLException.class)
private void assertOneThreadResult() {
backendConnection.getTransactionStatus().setInTransaction(true);
List<Connection> actualConnections = backendConnection.getConnections("ds1", 12, ConnectionMode.MEMORY_STRICTLY);
@@ -248,9 +249,8 @@ public final class BackendConnectionTest {
assertTrue(backendConnection.isSerialExecute());
}
- @SneakyThrows
@Test
- public void assertSetFetchSizeAsExpected() {
+ public void assertSetFetchSizeAsExpected() throws InvocationTargetException, IllegalAccessException, NoSuchMethodException, SQLException {
Statement statement = mock(Statement.class);
Method setFetchSizeMethod = backendConnection.getClass().getDeclaredMethod("setFetchSize", Statement.class);
setFetchSizeMethod.setAccessible(true);
@@ -258,9 +258,8 @@ public final class BackendConnectionTest {
verify(statement, times(1)).setFetchSize(Integer.MIN_VALUE);
}
- @SneakyThrows
@Test
- public void assertAddStatementCorrectly() {
+ public void assertAddStatementCorrectly() throws NoSuchFieldException, IllegalAccessException {
Statement statement = mock(Statement.class);
backendConnection.add(statement);
Field field = backendConnection.getClass().getDeclaredField("cachedStatements");
@@ -268,9 +267,8 @@ public final class BackendConnectionTest {
assertTrue(((Collection<Statement>) field.get(backendConnection)).contains(statement));
}
- @SneakyThrows
@Test
- public void assertAddResultSetCorrectly() {
+ public void assertAddResultSetCorrectly() throws NoSuchFieldException, IllegalAccessException {
ResultSet resultSet = mock(ResultSet.class);
backendConnection.add(resultSet);
Field field = backendConnection.getClass().getDeclaredField("cachedResultSets");
@@ -278,9 +276,8 @@ public final class BackendConnectionTest {
assertTrue(((Collection<ResultSet>) field.get(backendConnection)).contains(resultSet));
}
- @SneakyThrows
@Test
- public void assertCloseResultSetsCorrectly() {
+ public void assertCloseResultSetsCorrectly() throws NoSuchFieldException, SQLException, IllegalAccessException {
Field field = backendConnection.getClass().getDeclaredField("cachedResultSets");
field.setAccessible(true);
Collection<ResultSet> cachedResultSets = (Collection<ResultSet>) field.get(backendConnection);
@@ -291,9 +288,8 @@ public final class BackendConnectionTest {
assertTrue(cachedResultSets.isEmpty());
}
- @SneakyThrows
@Test
- public void assertCloseResultSetsWithExceptionThrown() {
+ public void assertCloseResultSetsWithExceptionThrown() throws NoSuchFieldException, SQLException, IllegalAccessException {
Field field = backendConnection.getClass().getDeclaredField("cachedResultSets");
field.setAccessible(true);
Collection<ResultSet> cachedResultSets = (Collection<ResultSet>) field.get(backendConnection);
@@ -307,9 +303,8 @@ public final class BackendConnectionTest {
assertTrue(result.contains(sqlException));
}
- @SneakyThrows
@Test
- public void assertCloseStatementsCorrectly() {
+ public void assertCloseStatementsCorrectly() throws NoSuchFieldException, SQLException, IllegalAccessException {
Field field = backendConnection.getClass().getDeclaredField("cachedStatements");
field.setAccessible(true);
Collection<Statement> cachedStatement = (Collection<Statement>) field.get(backendConnection);
@@ -320,9 +315,8 @@ public final class BackendConnectionTest {
assertTrue(cachedStatement.isEmpty());
}
- @SneakyThrows
@Test
- public void assertCloseStatementsWithExceptionThrown() {
+ public void assertCloseStatementsWithExceptionThrown() throws SQLException, NoSuchFieldException, IllegalAccessException {
Field field = backendConnection.getClass().getDeclaredField("cachedStatements");
field.setAccessible(true);
Collection<Statement> cachedStatement = (Collection<Statement>) field.get(backendConnection);
@@ -336,9 +330,8 @@ public final class BackendConnectionTest {
assertTrue(result.contains(sqlException));
}
- @SneakyThrows
@Test
- public void assertCloseConnectionsCorrectlyWhenNotForceRollback() {
+ public void assertCloseConnectionsCorrectlyWhenNotForceRollback() throws NoSuchFieldException, IllegalAccessException, SQLException {
Field field = backendConnection.getClass().getDeclaredField("cachedConnections");
field.setAccessible(true);
Multimap<String, Connection> cachedConnections = (Multimap<String, Connection>) field.get(backendConnection);
@@ -353,9 +346,8 @@ public final class BackendConnectionTest {
verify(connectionStatus, times(1)).switchToReleased();
}
- @SneakyThrows
@Test
- public void assertCloseConnectionsCorrectlyWhenForceRollbackAndNotInTransaction() {
+ public void assertCloseConnectionsCorrectlyWhenForceRollbackAndNotInTransaction() throws SQLException {
ConnectionStatus connectionStatus = mock(ConnectionStatus.class);
prepareConnectionStatus(connectionStatus);
backendConnection.getTransactionStatus().setInTransaction(false);
@@ -365,9 +357,8 @@ public final class BackendConnectionTest {
verify(connectionStatus, times(1)).switchToReleased();
}
- @SneakyThrows
@Test
- public void assertCloseConnectionsCorrectlyWhenForceRollbackAndInTransaction() {
+ public void assertCloseConnectionsCorrectlyWhenForceRollbackAndInTransaction() throws SQLException {
ConnectionStatus connectionStatus = mock(ConnectionStatus.class);
prepareConnectionStatus(connectionStatus);
backendConnection.getTransactionStatus().setInTransaction(true);
@@ -377,9 +368,8 @@ public final class BackendConnectionTest {
verify(connectionStatus, times(1)).switchToReleased();
}
- @SneakyThrows
@Test
- public void assertCloseConnectionsCorrectlyWhenSQLExceptionThrown() {
+ public void assertCloseConnectionsCorrectlyWhenSQLExceptionThrown() throws SQLException {
ConnectionStatus connectionStatus = mock(ConnectionStatus.class);
prepareConnectionStatus(connectionStatus);
Connection connection = prepareCachedConnections();
@@ -388,9 +378,8 @@ public final class BackendConnectionTest {
assertTrue(backendConnection.closeConnections(false).contains(sqlException));
}
- @SneakyThrows
@Test
- public void assertCreateStorageResourceCorrectlyWhenConnectionModeMemoryStrictly() {
+ public void assertCreateStorageResourceCorrectlyWhenConnectionModeMemoryStrictly() throws SQLException {
Connection connection = mock(Connection.class);
Statement statement = mock(Statement.class);
when(connection.createStatement()).thenReturn(statement);
@@ -398,9 +387,8 @@ public final class BackendConnectionTest {
verify(connection, times(1)).createStatement();
}
- @SneakyThrows
@Test
- public void assertGetConnectionsWithoutTransactions() {
+ public void assertGetConnectionsWithoutTransactions() throws SQLException {
backendConnection.getTransactionStatus().setInTransaction(false);
List<Connection> connectionList = MockConnectionUtil.mockNewConnections(1);
when(backendDataSource.getConnections(anyString(), anyString(), eq(1), any())).thenReturn(connectionList);
@@ -410,7 +398,8 @@ public final class BackendConnectionTest {
assertConnectionsCached("ds1", connectionList);
}
- @SneakyThrows
+ @SuppressWarnings("unchecked")
+ @SneakyThrows(ReflectiveOperationException.class)
private void assertConnectionsCached(final String dataSourceName, final Collection<Connection> collectionList) {
Field field = backendConnection.getClass().getDeclaredField("cachedConnections");
field.setAccessible(true);
@@ -419,7 +408,8 @@ public final class BackendConnectionTest {
assertArrayEquals(cachedConnections.get(dataSourceName).toArray(), collectionList.toArray());
}
- @SneakyThrows
+ @SuppressWarnings("unchecked")
+ @SneakyThrows(ReflectiveOperationException.class)
private Connection prepareCachedConnections() {
Field field = backendConnection.getClass().getDeclaredField("cachedConnections");
field.setAccessible(true);
@@ -429,14 +419,15 @@ public final class BackendConnectionTest {
return connection;
}
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
private void prepareConnectionStatus(final ConnectionStatus connectionStatus) {
Field field = backendConnection.getClass().getDeclaredField("connectionStatus");
field.setAccessible(true);
field.set(backendConnection, connectionStatus);
}
- @SneakyThrows
+ @SuppressWarnings("unchecked")
+ @SneakyThrows(ReflectiveOperationException.class)
private void verifyMethodInvocationsEmpty() {
Field field = backendConnection.getClass().getDeclaredField("methodInvocations");
field.setAccessible(true);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/MethodInvocationTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/MethodInvocationTest.java
index 41745cc..ad63f19 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/MethodInvocationTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/MethodInvocationTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.proxy.backend.communication.jdbc.connection;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.fixture.MethodInvocationFixture;
import org.junit.Test;
@@ -26,9 +25,8 @@ import static org.junit.Assert.assertThat;
public final class MethodInvocationTest {
- @SneakyThrows
@Test
- public void assertInvoke() {
+ public void assertInvoke() throws NoSuchMethodException {
MethodInvocationFixture methodInvocationFixture = new MethodInvocationFixture();
MethodInvocation methodInvocation = new MethodInvocation(MethodInvocationFixture.class.getMethod("setId", Integer.class), new Object[]{1});
methodInvocation.invoke(methodInvocationFixture);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/fetchsize/impl/MySQLStatementMemoryStrictlyFetchSizeSetterTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/fetchsize/impl/MySQLStatementMemoryStrictlyFetchSizeSetterTest.java
index 429e061..86f50a9 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/fetchsize/impl/MySQLStatementMemoryStrictlyFetchSizeSetterTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/fetchsize/impl/MySQLStatementMemoryStrictlyFetchSizeSetterTest.java
@@ -17,9 +17,9 @@
package org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.fetchsize.impl;
-import lombok.SneakyThrows;
import org.junit.Test;
+import java.sql.SQLException;
import java.sql.Statement;
import static org.hamcrest.CoreMatchers.is;
@@ -30,9 +30,8 @@ import static org.mockito.Mockito.verify;
public final class MySQLStatementMemoryStrictlyFetchSizeSetterTest {
- @SneakyThrows
@Test
- public void assertSetFetchSize() {
+ public void assertSetFetchSize() throws SQLException {
Statement statement = mock(Statement.class);
new MySQLStatementMemoryStrictlyFetchSizeSetter().setFetchSize(statement);
verify(statement, times(1)).setFetchSize(Integer.MIN_VALUE);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/fetchsize/impl/PostgreSQLStatementMemoryStrictlyFetchSizeSetterTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/fetchsize/impl/PostgreSQLStatementMemoryStrictlyFetchSizeSetterTest.java
index 88069eb..6dca066 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/fetchsize/impl/PostgreSQLStatementMemoryStrictlyFetchSizeSetterTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/fetchsize/impl/PostgreSQLStatementMemoryStrictlyFetchSizeSetterTest.java
@@ -17,9 +17,9 @@
package org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.fetchsize.impl;
-import lombok.SneakyThrows;
import org.junit.Test;
+import java.sql.SQLException;
import java.sql.Statement;
import static org.hamcrest.CoreMatchers.is;
@@ -30,9 +30,8 @@ import static org.mockito.Mockito.verify;
public final class PostgreSQLStatementMemoryStrictlyFetchSizeSetterTest {
- @SneakyThrows
@Test
- public void assertSetFetchSize() {
+ public void assertSetFetchSize() throws SQLException {
Statement statement = mock(Statement.class);
new PostgreSQLStatementMemoryStrictlyFetchSizeSetter().setFetchSize(statement);
verify(statement, times(1)).setFetchSize(1);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/BroadcastBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/BroadcastBackendHandlerTest.java
index d99091b..12d083f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/BroadcastBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/BroadcastBackendHandlerTest.java
@@ -70,8 +70,7 @@ public final class BroadcastBackendHandlerTest {
private DatabaseCommunicationEngine databaseCommunicationEngine;
@Before
- @SneakyThrows(ReflectiveOperationException.class)
- public void setUp() {
+ public void setUp() throws IllegalAccessException, NoSuchFieldException {
Field schemaContexts = ProxyContext.getInstance().getClass().getDeclaredField("schemaContexts");
schemaContexts.setAccessible(true);
schemaContexts.set(ProxyContext.getInstance(), new StandardSchemaContexts(getSchemas(),
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/DALBackendHandlerFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/DALBackendHandlerFactoryTest.java
index 182ed02..54163ab 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/DALBackendHandlerFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/DALBackendHandlerFactoryTest.java
@@ -93,7 +93,8 @@ public final class DALBackendHandlerFactoryTest {
assertFieldOfInstance(unicastBackendHandler, "backendConnection", is(backendConnection));
}
- @SneakyThrows
+ @SuppressWarnings("unchecked")
+ @SneakyThrows(ReflectiveOperationException.class)
private <S, T> void assertFieldOfInstance(final S classInstance, final String fieldName, final Matcher<T> matcher) {
Field field = classInstance.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandlerTest.java
index b2e2c2e..754f116 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandlerTest.java
@@ -59,8 +59,7 @@ import static org.mockito.Mockito.when;
public final class RDLBackendHandlerTest {
@Before
- @SneakyThrows(ReflectiveOperationException.class)
- public void setUp() {
+ public void setUp() throws IllegalAccessException, NoSuchFieldException {
Field schemaContexts = ProxyContext.getInstance().getClass().getDeclaredField("schemaContexts");
schemaContexts.setAccessible(true);
schemaContexts.set(ProxyContext.getInstance(), new StandardSchemaContexts(getSchemas(),
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/ShowDatabasesBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/ShowDatabasesBackendHandlerTest.java
index a5a2145..b071744 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/ShowDatabasesBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/ShowDatabasesBackendHandlerTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.proxy.backend.text.admin;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.auth.Authentication;
import org.apache.shardingsphere.infra.auth.ProxyUser;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
@@ -57,8 +56,7 @@ public final class ShowDatabasesBackendHandlerTest {
private ShowDatabasesBackendHandler showDatabasesBackendHandler;
@Before
- @SneakyThrows(ReflectiveOperationException.class)
- public void setUp() {
+ public void setUp() throws IllegalAccessException, NoSuchFieldException {
BackendConnection backendConnection = mock(BackendConnection.class);
when(backendConnection.getUsername()).thenReturn("root");
showDatabasesBackendHandler = new ShowDatabasesBackendHandler(backendConnection);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/ShowTablesBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/ShowTablesBackendHandlerTest.java
index 1a44c0c..083f294 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/ShowTablesBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/ShowTablesBackendHandlerTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.proxy.backend.text.admin;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.auth.Authentication;
import org.apache.shardingsphere.infra.auth.ProxyUser;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
@@ -56,8 +55,7 @@ public final class ShowTablesBackendHandlerTest {
private ShowTablesBackendHandler tablesBackendHandler;
@Before
- @SneakyThrows(ReflectiveOperationException.class)
- public void setUp() {
+ public void setUp() throws NoSuchFieldException, IllegalAccessException {
BackendConnection backendConnection = mock(BackendConnection.class);
when(backendConnection.getUsername()).thenReturn("root");
tablesBackendHandler = new ShowTablesBackendHandler("show tables", mock(SQLStatement.class), backendConnection);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandlerTest.java
index 8a8960a..94c8d11 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandlerTest.java
@@ -1,6 +1,5 @@
package org.apache.shardingsphere.proxy.backend.text.sctl.explain;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.auth.Authentication;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.schema.impl.StandardSchemaContexts;
@@ -50,8 +49,7 @@ public final class ShardingCTLExplainBackendHandlerTest {
private ShardingCTLExplainBackendHandler handler;
@Before
- @SneakyThrows(ReflectiveOperationException.class)
- public void setUp() {
+ public void setUp() throws IllegalAccessException, NoSuchFieldException {
BackendConnection connection = mock(BackendConnection.class);
when(connection.getSchemaName()).thenReturn("schema");
handler = new ShardingCTLExplainBackendHandler("sctl:explain select 1", connection);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java
index 08583e2..20f9ef0 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.proxy.backend.text.sctl.hint;
import com.google.common.collect.ImmutableMap;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.auth.Authentication;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
@@ -168,8 +167,7 @@ public final class ShardingCTLHintBackendHandlerTest {
}
@Test
- @SneakyThrows(ReflectiveOperationException.class)
- public void assertShowTableStatus() throws SQLException {
+ public void assertShowTableStatus() throws SQLException, NoSuchFieldException, IllegalAccessException {
clearThreadLocal();
when(backendConnection.getSchemaName()).thenReturn("schema");
Field schemaContexts = ProxyContext.getInstance().getClass().getDeclaredField("schemaContexts");
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetBackendHandlerTest.java
index 1b3840f..184ee1f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetBackendHandlerTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.proxy.backend.text.sctl.set;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.auth.Authentication;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.schema.impl.StandardSchemaContexts;
@@ -52,8 +51,7 @@ public final class ShardingCTLSetBackendHandlerTest {
private final BackendConnection backendConnection = new BackendConnection(TransactionType.LOCAL);
@Before
- @SneakyThrows(ReflectiveOperationException.class)
- public void setUp() {
+ public void setUp() throws NoSuchFieldException, IllegalAccessException {
Field schemaContexts = ProxyContext.getInstance().getClass().getDeclaredField("schemaContexts");
schemaContexts.setAccessible(true);
schemaContexts.set(ProxyContext.getInstance(), new StandardSchemaContexts(getSchemas(),
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandlerFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandlerFactoryTest.java
index f3199b4..e0580d9 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandlerFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandlerFactoryTest.java
@@ -64,7 +64,8 @@ public final class TransactionBackendHandlerFactoryTest {
assertThat(TransactionBackendHandlerFactory.newInstance(null, mock(TCLStatement.class), null), instanceOf(BroadcastBackendHandler.class));
}
- @SneakyThrows
+ @SuppressWarnings("unchecked")
+ @SneakyThrows(ReflectiveOperationException.class)
private <S, T> void assertFieldOfInstance(final S classInstance, final String fieldName, final Matcher<T> matcher) {
Field field = classInstance.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
@@ -72,7 +73,7 @@ public final class TransactionBackendHandlerFactoryTest {
assertThat(value, matcher);
}
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
private BackendTransactionManager getBackendTransactionManager(final TransactionBackendHandler transactionBackendHandler) {
Field field = transactionBackendHandler.getClass().getDeclaredField("backendTransactionManager");
field.setAccessible(true);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/init/impl/AbstractBootstrapInitializerTest.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/init/impl/AbstractBootstrapInitializerTest.java
index 4040da2..45ca17e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/init/impl/AbstractBootstrapInitializerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/init/impl/AbstractBootstrapInitializerTest.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.proxy.init.impl;
import lombok.Getter;
import lombok.Setter;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.schema.SchemaContexts;
import org.apache.shardingsphere.proxy.config.ProxyConfiguration;
@@ -33,6 +32,7 @@ import org.mockito.Mockito;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
+import java.sql.SQLException;
import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
@@ -64,9 +64,8 @@ public abstract class AbstractBootstrapInitializerTest {
protected abstract void prepareSpecifiedInitializer();
- @SneakyThrows
@Test
- public final void assertInit() {
+ public final void assertInit() throws NoSuchFieldException, IllegalAccessException, SQLException {
Field field = AbstractBootstrapInitializer.class.getDeclaredField("shardingSphereProxy");
field.setAccessible(true);
Field modifiersField = Field.class.getDeclaredField("modifiers");
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/init/impl/GovernanceBootstrapInitializerTest.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/init/impl/GovernanceBootstrapInitializerTest.java
index a4abe00..652357f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/init/impl/GovernanceBootstrapInitializerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/init/impl/GovernanceBootstrapInitializerTest.java
@@ -39,6 +39,7 @@ import org.apache.shardingsphere.transaction.context.TransactionContexts;
import org.junit.Test;
import java.io.IOException;
+import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Collection;
@@ -74,7 +75,7 @@ public final class GovernanceBootstrapInitializerTest extends AbstractBootstrapI
closeConfigCenter();
}
- @SneakyThrows
+ @SneakyThrows(IOException.class)
protected YamlProxyConfiguration makeProxyConfiguration() {
return ProxyConfigurationLoader.load("/conf/reg_center/");
}
@@ -88,7 +89,7 @@ public final class GovernanceBootstrapInitializerTest extends AbstractBootstrapI
configurationRepository.persist(node.getRulePath("db"), readYAML(SHARDING_RULE_YAML));
}
- @SneakyThrows
+ @SneakyThrows({URISyntaxException.class, IOException.class})
private String readYAML(final String yamlFile) {
return Files.readAllLines(Paths.get(ClassLoader.getSystemResource(yamlFile).toURI()))
.stream().map(each -> each + System.lineSeparator()).collect(Collectors.joining());
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/init/impl/StandardBootstrapInitializerTest.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/init/impl/StandardBootstrapInitializerTest.java
index f373159..1e51407 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/init/impl/StandardBootstrapInitializerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/init/impl/StandardBootstrapInitializerTest.java
@@ -17,14 +17,13 @@
package org.apache.shardingsphere.proxy.init.impl;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.auth.Authentication;
import org.apache.shardingsphere.infra.auth.ProxyUser;
import org.apache.shardingsphere.infra.auth.yaml.config.YamlAuthenticationConfiguration;
import org.apache.shardingsphere.infra.auth.yaml.config.YamlProxyUserConfiguration;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import org.apache.shardingsphere.infra.context.schema.SchemaContexts;
import org.apache.shardingsphere.infra.config.datasource.DataSourceParameter;
+import org.apache.shardingsphere.infra.context.schema.SchemaContexts;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration;
import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapper;
@@ -54,7 +53,6 @@ import static org.mockito.Mockito.mock;
public final class StandardBootstrapInitializerTest extends AbstractBootstrapInitializerTest {
- @SneakyThrows
protected YamlProxyConfiguration makeProxyConfiguration() {
return new YamlProxyConfiguration(createYamlProxyServerConfiguration(), createYamlProxyRuleConfigurationMap());
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlDataSourceParameterMerger.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlDataSourceParameterMerger.java
index bca442c..b8c6515 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlDataSourceParameterMerger.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlDataSourceParameterMerger.java
@@ -59,7 +59,7 @@ public final class YamlDataSourceParameterMerger {
}
}
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
private static Object getValue(final Field field, final Class<?> clazz, final Object source) {
String fieldName = field.getName();
String firstLetter = fieldName.substring(0, 1).toUpperCase();
@@ -73,7 +73,7 @@ public final class YamlDataSourceParameterMerger {
return getMethod.invoke(source);
}
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
private static void setValue(final Field field, final Class<?> clazz, final Object source, final Map<String, Object> commonProps) {
String fieldName = field.getName();
String firstLetter = fieldName.substring(0, 1).toUpperCase();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationHandlerTest.java
index 4821cdf..387ebcb 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationHandlerTest.java
@@ -60,7 +60,7 @@ public final class MySQLAuthenticationHandlerTest {
initAuthPluginDataForAuthenticationHandler();
}
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
private void initAuthPluginDataForAuthenticationHandler() {
MySQLAuthPluginData authPluginData = new MySQLAuthPluginData(part1, part2);
Field field = MySQLAuthenticationHandler.class.getDeclaredField("authPluginData");
@@ -108,14 +108,13 @@ public final class MySQLAuthenticationHandlerTest {
assertThat(authenticationHandler.getAuthPluginData().getAuthPluginData(), is(Bytes.concat(part1, part2)));
}
- @SneakyThrows
private void setAuthentication(final ProxyUser proxyUser) {
Authentication authentication = new Authentication();
authentication.getUsers().put("root", proxyUser);
initProxyContext(authentication);
}
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
private void initProxyContext(final Authentication authentication) {
Field field = ProxyContext.getInstance().getClass().getDeclaredField("schemaContexts");
field.setAccessible(true);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java
index 181f512..34a86b8 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.proxy.frontend.postgresql.command;
import io.netty.channel.ChannelHandlerContext;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLReadyForQueryPacket;
import org.apache.shardingsphere.proxy.frontend.command.executor.QueryCommandExecutor;
import org.apache.shardingsphere.proxy.frontend.command.executor.ResponseType;
@@ -27,6 +26,8 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import java.sql.SQLException;
+
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -42,8 +43,7 @@ public final class PostgreSQLCommandExecuteEngineTest {
private QueryCommandExecutor queryCommandExecutor;
@Test
- @SneakyThrows
- public void assertWriteQueryDataWithUpdate() {
+ public void assertWriteQueryDataWithUpdate() throws SQLException {
PostgreSQLCommandExecuteEngine postgreSQLCommandExecuteEngine = new PostgreSQLCommandExecuteEngine();
when(queryCommandExecutor.getResponseType()).thenReturn(ResponseType.UPDATE);
postgreSQLCommandExecuteEngine.writeQueryData(channelHandlerContext, null, queryCommandExecutor, 0);
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/datasource/DataSourceFactory.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/datasource/DataSourceFactory.java
index 7785ff9..f40a1e7 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/datasource/DataSourceFactory.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/datasource/DataSourceFactory.java
@@ -29,6 +29,7 @@ import org.apache.shardingsphere.scaling.core.utils.ConfigurationYamlConverter;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import javax.sql.DataSource;
+import java.sql.SQLException;
import java.util.Map;
/**
@@ -59,7 +60,7 @@ public final class DataSourceFactory {
return new DataSourceWrapper(result);
}
- @SneakyThrows
+ @SneakyThrows(SQLException.class)
private DataSourceWrapper newInstanceDataSourceByShardingSphereJDBC(final ShardingSphereJDBCConfiguration dataSourceConfig) {
Map<String, DataSource> dataSourceMap = DataSourceConverter.getDataSourceMap(
ConfigurationYamlConverter.loadDataSourceConfigurations(dataSourceConfig.getDataSource()));
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/dumper/DumperFactory.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/dumper/DumperFactory.java
index 9759b64..a06a7f4 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/dumper/DumperFactory.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/dumper/DumperFactory.java
@@ -40,7 +40,6 @@ public final class DumperFactory {
* @param dataSourceManager data source factory
* @return JDBC dumper
*/
- @SneakyThrows
public static JDBCDumper newInstanceJdbcDumper(final InventoryDumperConfiguration inventoryDumperConfig, final DataSourceManager dataSourceManager) {
return newInstanceJdbcDumper(inventoryDumperConfig.getDataSourceConfiguration().getDatabaseType().getName(), inventoryDumperConfig, dataSourceManager);
}
@@ -53,7 +52,7 @@ public final class DumperFactory {
* @param dataSourceManager data source factory
* @return JDBC dumper
*/
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
public static JDBCDumper newInstanceJdbcDumper(final String databaseType, final InventoryDumperConfiguration inventoryDumperConfig, final DataSourceManager dataSourceManager) {
ScalingEntry scalingEntry = ScalingEntryLoader.getScalingEntryByDatabaseType(databaseType);
return scalingEntry.getJdbcDumperClass().getConstructor(InventoryDumperConfiguration.class, DataSourceManager.class).newInstance(inventoryDumperConfig, dataSourceManager);
@@ -66,7 +65,6 @@ public final class DumperFactory {
* @param position position
* @return log dumper
*/
- @SneakyThrows
public static LogDumper newInstanceLogDumper(final DumperConfiguration dumperConfig, final Position position) {
return newInstanceLogDumper(dumperConfig.getDataSourceConfiguration().getDatabaseType().getName(), dumperConfig, position);
}
@@ -79,7 +77,7 @@ public final class DumperFactory {
* @param position position
* @return log dumper
*/
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
public static LogDumper newInstanceLogDumper(final String databaseType, final DumperConfiguration dumperConfig, final Position position) {
ScalingEntry scalingEntry = ScalingEntryLoader.getScalingEntryByDatabaseType(databaseType);
return scalingEntry.getLogDumperClass().getConstructor(DumperConfiguration.class, Position.class).newInstance(dumperConfig, position);
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/ImporterFactory.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/ImporterFactory.java
index 72314e0..ba00e27 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/ImporterFactory.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/ImporterFactory.java
@@ -50,7 +50,7 @@ public final class ImporterFactory {
* @param dataSourceManager data source factory
* @return importer
*/
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
public static Importer newInstance(final String databaseType, final ImporterConfiguration importerConfig, final DataSourceManager dataSourceManager) {
ScalingEntry scalingEntry = ScalingEntryLoader.getScalingEntryByDatabaseType(databaseType);
return scalingEntry.getImporterClass().getConstructor(ImporterConfiguration.class, DataSourceManager.class).newInstance(importerConfig, dataSourceManager);
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/ScalingJobControllerTest.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/ScalingJobControllerTest.java
index a8fdd47..6fa0551 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/ScalingJobControllerTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/ScalingJobControllerTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.scaling.core;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.scaling.core.config.DataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.config.DumperConfiguration;
import org.apache.shardingsphere.scaling.core.config.ImporterConfiguration;
@@ -110,8 +109,7 @@ public final class ScalingJobControllerTest {
}
@Test
- @SneakyThrows(ReflectiveOperationException.class)
- public void assertOnlyIncrementalDataTasks() {
+ public void assertOnlyIncrementalDataTasks() throws NoSuchFieldException, IllegalAccessException {
ReflectionUtil.setFieldValue(ResumeBreakPointManagerFactory.class, null, "clazz", IncrementalPositionResumeBreakPointManager.class);
ShardingScalingJob shardingScalingJob = mockShardingScalingJob();
scalingJobController.start(shardingScalingJob);
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/channel/DistributionChannelTest.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/channel/DistributionChannelTest.java
index 554ec2e..da90681 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/channel/DistributionChannelTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/channel/DistributionChannelTest.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.scaling.core.execute.executor.channel;
import com.google.gson.JsonElement;
import lombok.AllArgsConstructor;
import lombok.Getter;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.scaling.core.config.ScalingContext;
import org.apache.shardingsphere.scaling.core.config.ServerConfiguration;
import org.apache.shardingsphere.scaling.core.execute.executor.record.FinishedRecord;
@@ -33,6 +32,8 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import java.lang.reflect.InvocationTargetException;
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@@ -47,8 +48,7 @@ public final class DistributionChannelTest {
}
@Test
- @SneakyThrows({InterruptedException.class, ReflectiveOperationException.class})
- public void assertAckCallbackResultSortable() {
+ public void assertAckCallbackResultSortable() throws InterruptedException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
distributionChannel = new DistributionChannel(2, records -> {
assertThat(records.size(), is(2));
assertTrue(((IntPosition) records.get(0).getPosition()).getId() < ((IntPosition) records.get(1).getPosition()).getId());
@@ -71,8 +71,7 @@ public final class DistributionChannelTest {
}
@Test
- @SneakyThrows(InterruptedException.class)
- public void assertBroadcastFinishedRecord() {
+ public void assertBroadcastFinishedRecord() throws InterruptedException {
distributionChannel = new DistributionChannel(2, records -> assertThat(records.size(), is(2)));
distributionChannel.pushRecord(new FinishedRecord(new NopPosition()));
}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/AbstractJDBCImporterTest.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/AbstractJDBCImporterTest.java
index 17a707e..188a19e 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/AbstractJDBCImporterTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/AbstractJDBCImporterTest.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.scaling.core.execute.executor.importer;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.scaling.core.config.DataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.config.ImporterConfiguration;
import org.apache.shardingsphere.scaling.core.datasource.DataSourceManager;
@@ -98,8 +97,7 @@ public final class AbstractJDBCImporterTest {
}
@Test
- @SneakyThrows
- public void assertWriteInsertDataRecord() {
+ public void assertWriteInsertDataRecord() throws SQLException {
DataRecord insertRecord = getDataRecord("INSERT");
when(sqlBuilder.buildInsertSQL(insertRecord)).thenReturn(INSERT_SQL);
when(connection.prepareStatement(INSERT_SQL)).thenReturn(preparedStatement);
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/AbstractSqlBuilderTest.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/AbstractSqlBuilderTest.java
index efe2971..c61a481 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/AbstractSqlBuilderTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/AbstractSqlBuilderTest.java
@@ -18,11 +18,10 @@
package org.apache.shardingsphere.scaling.core.execute.executor.importer;
import com.google.common.collect.Sets;
-import lombok.SneakyThrows;
-import org.apache.shardingsphere.scaling.core.execute.executor.record.RecordUtil;
-import org.apache.shardingsphere.scaling.core.job.position.NopPosition;
import org.apache.shardingsphere.scaling.core.execute.executor.record.Column;
import org.apache.shardingsphere.scaling.core.execute.executor.record.DataRecord;
+import org.apache.shardingsphere.scaling.core.execute.executor.record.RecordUtil;
+import org.apache.shardingsphere.scaling.core.job.position.NopPosition;
import org.junit.Before;
import org.junit.Test;
@@ -36,7 +35,6 @@ public class AbstractSqlBuilderTest {
private AbstractSQLBuilder sqlBuilder;
@Before
- @SneakyThrows
public void setUp() {
sqlBuilder = new AbstractSQLBuilder() {
@@ -53,32 +51,32 @@ public class AbstractSqlBuilderTest {
}
@Test
- public void assertBuildInsertSql() {
+ public void assertBuildInsertSQL() {
String actual = sqlBuilder.buildInsertSQL(mockDataRecord("t1"));
assertThat(actual, is("INSERT INTO `t1`(`id`,`sc`,`c1`,`c2`,`c3`) VALUES(?,?,?,?,?)"));
}
@Test
- public void assertBuildUpdateSqlWithPrimaryKey() {
+ public void assertBuildUpdateSQLWithPrimaryKey() {
String actual = sqlBuilder.buildUpdateSQL(mockDataRecord("t2"), RecordUtil.extractPrimaryColumns(mockDataRecord("t2")));
assertThat(actual, is("UPDATE `t2` SET `c1` = ?,`c2` = ?,`c3` = ? WHERE `id` = ?"));
}
@Test
- public void assertBuildUpdateSqlWithShardingColumns() {
+ public void assertBuildUpdateSQLWithShardingColumns() {
DataRecord dataRecord = mockDataRecord("t2");
String actual = sqlBuilder.buildUpdateSQL(dataRecord, mockConditionColumns(dataRecord));
assertThat(actual, is("UPDATE `t2` SET `c1` = ?,`c2` = ?,`c3` = ? WHERE `id` = ? and `sc` = ?"));
}
@Test
- public void assertBuildDeleteSqlWithPrimaryKey() {
+ public void assertBuildDeleteSQLWithPrimaryKey() {
String actual = sqlBuilder.buildDeleteSQL(mockDataRecord("t3"), RecordUtil.extractPrimaryColumns(mockDataRecord("t3")));
assertThat(actual, is("DELETE FROM `t3` WHERE `id` = ?"));
}
@Test
- public void assertBuildDeleteSqlWithConditionColumns() {
+ public void assertBuildDeleteSQLWithConditionColumns() {
DataRecord dataRecord = mockDataRecord("t3");
String actual = sqlBuilder.buildDeleteSQL(dataRecord, mockConditionColumns(dataRecord));
assertThat(actual, is("DELETE FROM `t3` WHERE `id` = ? and `sc` = ?"));
diff --git a/shardingsphere-scaling/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/MySQLJdbcDumperTest.java b/shardingsphere-scaling/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/MySQLJdbcDumperTest.java
index cb6d99d..a97ae58 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/MySQLJdbcDumperTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/MySQLJdbcDumperTest.java
@@ -78,8 +78,7 @@ public final class MySQLJdbcDumperTest {
}
@Test
- @SneakyThrows(SQLException.class)
- public void assertReadValue() {
+ public void assertReadValue() throws SQLException {
ResultSet resultSet = mock(ResultSet.class);
ResultSetMetaData resultSetMetaData = mock(ResultSetMetaData.class);
when(resultSet.getMetaData()).thenReturn(resultSetMetaData);
@@ -92,8 +91,7 @@ public final class MySQLJdbcDumperTest {
}
@Test
- @SneakyThrows(SQLException.class)
- public void assertCreatePreparedStatement() {
+ public void assertCreatePreparedStatement() throws SQLException {
DataSource dataSource = dataSourceManager.getDataSource(mockDumperConfiguration().getDataSourceConfiguration());
try (Connection connection = dataSource.getConnection();
PreparedStatement preparedStatement = mySQLJdbcDumper.createPreparedStatement(connection, "SELECT * FROM t_order")) {
diff --git a/shardingsphere-scaling/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/MySQLPositionManagerTest.java b/shardingsphere-scaling/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/MySQLPositionManagerTest.java
index d0bfcca..519d65e 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/MySQLPositionManagerTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/MySQLPositionManagerTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.scaling.mysql;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.scaling.mysql.binlog.BinlogPosition;
import org.junit.Before;
import org.junit.Test;
@@ -52,8 +51,7 @@ public final class MySQLPositionManagerTest {
private Connection connection;
@Before
- @SneakyThrows(SQLException.class)
- public void setUp() {
+ public void setUp() throws SQLException {
when(dataSource.getConnection()).thenReturn(connection);
PreparedStatement positionStatement = mockPositionStatement();
when(connection.prepareStatement("SHOW MASTER STATUS")).thenReturn(positionStatement);
diff --git a/shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLDataSourceCheckerTest.java b/shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLDataSourceCheckerTest.java
index 51376cf..6f11daa 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLDataSourceCheckerTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLDataSourceCheckerTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.scaling.postgresql;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.scaling.core.exception.PrepareFailedException;
import org.junit.Before;
import org.junit.Test;
@@ -67,8 +66,7 @@ public final class PostgreSQLDataSourceCheckerTest {
dataSources.add(dataSource);
}
- @SneakyThrows
- private Connection mockConnection() {
+ private Connection mockConnection() throws SQLException {
when(connection.getMetaData()).thenReturn(metaData);
when(connection.getCatalog()).thenReturn(CATALOG);
when(connection.prepareStatement("SELECT * FROM test LIMIT 1")).thenReturn(preparedStatement);
diff --git a/shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLJdbcDumperTest.java b/shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLJdbcDumperTest.java
index c7e956b..5a0ee82 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLJdbcDumperTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLJdbcDumperTest.java
@@ -66,8 +66,7 @@ public final class PostgreSQLJdbcDumperTest {
}
@Test
- @SneakyThrows(SQLException.class)
- public void assertCreatePreparedStatement() {
+ public void assertCreatePreparedStatement() throws SQLException {
DataSource dataSource = dataSourceManager.getDataSource(mockDumperConfiguration().getDataSourceConfiguration());
try (Connection connection = dataSource.getConnection();
PreparedStatement preparedStatement = postgreSQLJdbcDumper.createPreparedStatement(connection, "SELECT * FROM t_order")) {
diff --git a/shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLPositionManagerTest.java b/shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLPositionManagerTest.java
index 111b1c1..e3cff80 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLPositionManagerTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLPositionManagerTest.java
@@ -55,8 +55,7 @@ public final class PostgreSQLPositionManagerTest {
private DatabaseMetaData databaseMetaData;
@Before
- @SneakyThrows(SQLException.class)
- public void setUp() {
+ public void setUp() throws SQLException {
when(dataSource.getConnection()).thenReturn(connection);
when(connection.getMetaData()).thenReturn(databaseMetaData);
PreparedStatement postgreSQL96LsnPs = mockPostgreSQL96Lsn();
@@ -75,8 +74,7 @@ public final class PostgreSQLPositionManagerTest {
}
@Test
- @SneakyThrows(SQLException.class)
- public void assertGetCurrentPositionOnPostgreSQL96() {
+ public void assertGetCurrentPositionOnPostgreSQL96() throws SQLException {
PostgreSQLPositionManager postgreSQLPositionManager = new PostgreSQLPositionManager(dataSource);
when(databaseMetaData.getDatabaseMajorVersion()).thenReturn(9);
when(databaseMetaData.getDatabaseMinorVersion()).thenReturn(6);
@@ -85,8 +83,7 @@ public final class PostgreSQLPositionManagerTest {
}
@Test
- @SneakyThrows(SQLException.class)
- public void assertGetCurrentPositionOnPostgreSQL10() {
+ public void assertGetCurrentPositionOnPostgreSQL10() throws SQLException {
PostgreSQLPositionManager postgreSQLPositionManager = new PostgreSQLPositionManager(dataSource);
when(databaseMetaData.getDatabaseMajorVersion()).thenReturn(10);
WalPosition actual = postgreSQLPositionManager.getPosition();
@@ -94,8 +91,7 @@ public final class PostgreSQLPositionManagerTest {
}
@Test(expected = RuntimeException.class)
- @SneakyThrows(SQLException.class)
- public void assertGetCurrentPositionThrowException() {
+ public void assertGetCurrentPositionThrowException() throws SQLException {
PostgreSQLPositionManager postgreSQLPositionManager = new PostgreSQLPositionManager(dataSource);
when(databaseMetaData.getDatabaseMajorVersion()).thenReturn(9);
when(databaseMetaData.getDatabaseMinorVersion()).thenReturn(4);
diff --git a/shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLWalDumperTest.java b/shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLWalDumperTest.java
index 0592d4f..b4897c5 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLWalDumperTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLWalDumperTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.scaling.postgresql;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.scaling.core.config.DumperConfiguration;
import org.apache.shardingsphere.scaling.core.config.JDBCDataSourceConfiguration;
import org.apache.shardingsphere.scaling.core.config.ScalingContext;
@@ -81,8 +80,7 @@ public final class PostgreSQLWalDumperTest {
}
@Test
- @SneakyThrows({ReflectiveOperationException.class, SQLException.class})
- public void assertStart() {
+ public void assertStart() throws SQLException, NoSuchFieldException, IllegalAccessException {
try {
ReflectionUtil.setFieldValueToClass(postgreSQLWalDumper, "logicalReplication", logicalReplication);
when(logicalReplication.createPgConnection(jdbcDataSourceConfig)).thenReturn(pgConnection);
diff --git a/shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/wal/LogicalReplicationTest.java b/shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/wal/LogicalReplicationTest.java
index 1935180..aa8dd46 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/wal/LogicalReplicationTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/wal/LogicalReplicationTest.java
@@ -63,16 +63,14 @@ public final class LogicalReplicationTest {
}
@Test
- @SneakyThrows(SQLException.class)
- public void assertCreatePgConnectionSuccess() {
+ public void assertCreatePgConnectionSuccess() throws SQLException {
Connection pgConnection = logicalReplication.createPgConnection(
new JDBCDataSourceConfiguration("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=PostgreSQL", "root", "root"));
assertFalse(pgConnection.isClosed());
}
@Test
- @SneakyThrows(SQLException.class)
- public void assertCreateReplicationStreamSuccess() {
+ public void assertCreateReplicationStreamSuccess() throws SQLException {
LogSequenceNumber startPosition = LogSequenceNumber.valueOf(100L);
when(pgConnection.unwrap(PGConnection.class)).thenReturn(pgConnection);
when(pgConnection.getReplicationAPI()).thenReturn(pgReplicationConnection);
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/ParseTreeVisitorFactory.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/ParseTreeVisitorFactory.java
index 4a10953..c0108c3 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/ParseTreeVisitorFactory.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/ParseTreeVisitorFactory.java
@@ -44,7 +44,7 @@ public final class ParseTreeVisitorFactory {
return createParseTreeVisitor(SQLParserConfigurationRegistry.getInstance().getSQLParserConfiguration(databaseTypeName), visitorRule.getType());
}
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
private static ParseTreeVisitor createParseTreeVisitor(final SQLParserConfiguration config, final SQLStatementType type) {
SQLVisitorFacade visitorFacade = config.getVisitorFacadeClass().getConstructor().newInstance();
switch (type) {
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/SafeNumberOperationUtils.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/SafeNumberOperationUtils.java
index b12469f..0be27b9 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/SafeNumberOperationUtils.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/SafeNumberOperationUtils.java
@@ -164,7 +164,7 @@ public final class SafeNumberOperationUtils {
return null;
}
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
private static Comparable<?> parseNumberByClazz(final String number, final Class<?> clazz) {
return (Comparable<?>) clazz.getConstructor(String.class).newInstance(number);
}
diff --git a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-atomikos/src/main/java/org/apache/shardingsphere/transaction/xa/atomikos/manager/AtomikosTransactionManager.java b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-atomikos/src/main/java/org/apache/shardingsphere/transaction/xa/atomikos/manager/AtomikosTransactionManager.java
index 0843d90..3dc3851 100644
--- a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-atomikos/src/main/java/org/apache/shardingsphere/transaction/xa/atomikos/manager/AtomikosTransactionManager.java
+++ b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-atomikos/src/main/java/org/apache/shardingsphere/transaction/xa/atomikos/manager/AtomikosTransactionManager.java
@@ -25,6 +25,8 @@ import org.apache.shardingsphere.transaction.xa.spi.SingleXAResource;
import org.apache.shardingsphere.transaction.xa.spi.XATransactionManager;
import javax.sql.XADataSource;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
/**
@@ -51,8 +53,8 @@ public final class AtomikosTransactionManager implements XATransactionManager {
userTransactionService.removeResource(new AtomikosXARecoverableResource(dataSourceName, xaDataSource));
}
+ @SneakyThrows({SystemException.class, RollbackException.class})
@Override
- @SneakyThrows
public void enlistResource(final SingleXAResource xaResource) {
transactionManager.getTransaction().enlistResource(xaResource);
}
diff --git a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-bitronix/src/main/java/org/apache/shardingsphere/transaction/xa/bitronix/manager/BitronixRecoveryResource.java b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-bitronix/src/main/java/org/apache/shardingsphere/transaction/xa/bitronix/manager/BitronixRecoveryResource.java
index d3e1a2b..782f4bd 100644
--- a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-bitronix/src/main/java/org/apache/shardingsphere/transaction/xa/bitronix/manager/BitronixRecoveryResource.java
+++ b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-bitronix/src/main/java/org/apache/shardingsphere/transaction/xa/bitronix/manager/BitronixRecoveryResource.java
@@ -30,6 +30,7 @@ import javax.naming.Reference;
import javax.sql.XAConnection;
import javax.sql.XADataSource;
import javax.transaction.xa.XAResource;
+import java.sql.SQLException;
/**
* Bitronix recovery resource.
@@ -54,7 +55,7 @@ public final class BitronixRecoveryResource extends ResourceBean implements XARe
return resourceName;
}
- @SneakyThrows
+ @SneakyThrows(SQLException.class)
@Override
public XAResourceHolderState startRecovery() {
xaConnection = xaDataSource.getXAConnection();
@@ -62,7 +63,7 @@ public final class BitronixRecoveryResource extends ResourceBean implements XARe
return new XAResourceHolderState(singleXAResourceHolder, this);
}
- @SneakyThrows
+ @SneakyThrows(SQLException.class)
@Override
public void endRecovery() {
if (null != xaConnection) {
diff --git a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-bitronix/src/main/java/org/apache/shardingsphere/transaction/xa/bitronix/manager/BitronixXATransactionManager.java b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-bitronix/src/main/java/org/apache/shardingsphere/transaction/xa/bitronix/manager/BitronixXATransactionManager.java
index 34df1f1..307916c 100644
--- a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-bitronix/src/main/java/org/apache/shardingsphere/transaction/xa/bitronix/manager/BitronixXATransactionManager.java
+++ b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-bitronix/src/main/java/org/apache/shardingsphere/transaction/xa/bitronix/manager/BitronixXATransactionManager.java
@@ -19,12 +19,15 @@ package org.apache.shardingsphere.transaction.xa.bitronix.manager;
import bitronix.tm.BitronixTransactionManager;
import bitronix.tm.TransactionManagerServices;
+import bitronix.tm.recovery.RecoveryException;
import bitronix.tm.resource.ResourceRegistrar;
import lombok.SneakyThrows;
import org.apache.shardingsphere.transaction.xa.spi.SingleXAResource;
import org.apache.shardingsphere.transaction.xa.spi.XATransactionManager;
import javax.sql.XADataSource;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
/**
@@ -38,19 +41,18 @@ public final class BitronixXATransactionManager implements XATransactionManager
public void init() {
}
- @SneakyThrows
+ @SneakyThrows(RecoveryException.class)
@Override
public void registerRecoveryResource(final String dataSourceName, final XADataSource xaDataSource) {
ResourceRegistrar.register(new BitronixRecoveryResource(dataSourceName, xaDataSource));
}
- @SneakyThrows
@Override
public void removeRecoveryResource(final String dataSourceName, final XADataSource xaDataSource) {
ResourceRegistrar.unregister(new BitronixRecoveryResource(dataSourceName, xaDataSource));
}
- @SneakyThrows
+ @SneakyThrows({SystemException.class, RollbackException.class})
@Override
public void enlistResource(final SingleXAResource singleXAResource) {
bitronixTransactionManager.getTransaction().enlistResource(singleXAResource);
diff --git a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-bitronix/src/test/java/org/apache/shardingsphere/transaction/xa/bitronix/manager/BitronixXATransactionManagerTest.java b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-bitronix/src/test/java/org/apache/shardingsphere/transaction/xa/bitronix/manager/BitronixXATransactionManagerTest.java
index 1f175aa..af35fdb 100644
--- a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-bitronix/src/test/java/org/apache/shardingsphere/transaction/xa/bitronix/manager/BitronixXATransactionManagerTest.java
+++ b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-bitronix/src/test/java/org/apache/shardingsphere/transaction/xa/bitronix/manager/BitronixXATransactionManagerTest.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.transaction.xa.bitronix.manager;
import bitronix.tm.BitronixTransactionManager;
import bitronix.tm.resource.ResourceRegistrar;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.transaction.xa.bitronix.manager.fixture.ReflectiveUtil;
import org.apache.shardingsphere.transaction.xa.spi.SingleXAResource;
import org.junit.Before;
@@ -30,8 +29,11 @@ import org.mockito.junit.MockitoJUnitRunner;
import javax.sql.XAConnection;
import javax.sql.XADataSource;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
import javax.transaction.Transaction;
import javax.transaction.xa.XAResource;
+import java.sql.SQLException;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
@@ -52,9 +54,8 @@ public final class BitronixXATransactionManagerTest {
@Mock
private XADataSource xaDataSource;
- @SneakyThrows
@Before
- public void setUp() {
+ public void setUp() throws SQLException {
ReflectiveUtil.setProperty(bitronixXATransactionManager, "bitronixTransactionManager", bitronixTransactionManager);
XAConnection xaConnection = mock(XAConnection.class);
XAResource xaResource = mock(XAResource.class);
@@ -70,9 +71,8 @@ public final class BitronixXATransactionManagerTest {
assertNull(ResourceRegistrar.get("ds1"));
}
- @SneakyThrows
@Test
- public void assertEnlistResource() {
+ public void assertEnlistResource() throws SystemException, RollbackException {
SingleXAResource singleXAResource = mock(SingleXAResource.class);
Transaction transaction = mock(Transaction.class);
when(bitronixTransactionManager.getTransaction()).thenReturn(transaction);
diff --git a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/XAShardingTransactionManager.java b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/XAShardingTransactionManager.java
index d8880f6..492ffa0 100644
--- a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/XAShardingTransactionManager.java
+++ b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/XAShardingTransactionManager.java
@@ -26,6 +26,9 @@ import org.apache.shardingsphere.transaction.xa.jta.datasource.XATransactionData
import org.apache.shardingsphere.transaction.xa.manager.XATransactionManagerLoader;
import org.apache.shardingsphere.transaction.xa.spi.XATransactionManager;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
import javax.transaction.RollbackException;
import javax.transaction.Status;
import javax.transaction.SystemException;
@@ -57,7 +60,7 @@ public final class XAShardingTransactionManager implements ShardingTransactionMa
return TransactionType.XA;
}
- @SneakyThrows
+ @SneakyThrows(SystemException.class)
@Override
public boolean isInTransaction() {
return Status.STATUS_NO_TRANSACTION != xaTransactionManager.getTransactionManager().getStatus();
@@ -72,19 +75,19 @@ public final class XAShardingTransactionManager implements ShardingTransactionMa
}
}
- @SneakyThrows
+ @SneakyThrows({SystemException.class, NotSupportedException.class})
@Override
public void begin() {
xaTransactionManager.getTransactionManager().begin();
}
- @SneakyThrows
+ @SneakyThrows({SystemException.class, RollbackException.class, HeuristicMixedException.class, HeuristicRollbackException.class})
@Override
public void commit() {
xaTransactionManager.getTransactionManager().commit();
}
- @SneakyThrows
+ @SneakyThrows(SystemException.class)
@Override
public void rollback() {
xaTransactionManager.getTransactionManager().rollback();
diff --git a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/H2XAConnectionWrapper.java b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/H2XAConnectionWrapper.java
index 1df394c..51adc06 100644
--- a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/H2XAConnectionWrapper.java
+++ b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/H2XAConnectionWrapper.java
@@ -29,6 +29,7 @@ import javax.sql.XADataSource;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.sql.Connection;
+import java.sql.SQLException;
/**
* XA connection wrapper for H2.
@@ -43,21 +44,21 @@ public final class H2XAConnectionWrapper implements XAConnectionWrapper {
private static final JdbcDataSourceFactory FACTORY = new JdbcDataSourceFactory();
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
private static Constructor<JdbcXAConnection> getH2JdbcXAConstructor() {
Constructor<JdbcXAConnection> result = JdbcXAConnection.class.getDeclaredConstructor(JdbcDataSourceFactory.class, Integer.TYPE, JdbcConnection.class);
result.setAccessible(true);
return result;
}
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
private static Method getNextIdMethod() {
Method result = TraceObject.class.getDeclaredMethod("getNextId", Integer.TYPE);
result.setAccessible(true);
return result;
}
- @SneakyThrows
+ @SneakyThrows({SQLException.class, ReflectiveOperationException.class})
@Override
public XAConnection wrap(final XADataSource xaDataSource, final Connection connection) {
Connection physicalConnection = connection.unwrap(JdbcConnection.class);
diff --git a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MariaDBXAConnectionWrapper.java b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MariaDBXAConnectionWrapper.java
index 6123e30..5eb271f 100644
--- a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MariaDBXAConnectionWrapper.java
+++ b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MariaDBXAConnectionWrapper.java
@@ -26,14 +26,15 @@ import org.mariadb.jdbc.MariaXaConnection;
import javax.sql.XAConnection;
import javax.sql.XADataSource;
import java.sql.Connection;
+import java.sql.SQLException;
/**
* XA connection wrapper for MariaDB.
*/
@RequiredArgsConstructor
public final class MariaDBXAConnectionWrapper implements XAConnectionWrapper {
-
- @SneakyThrows
+
+ @SneakyThrows({SQLException.class, ReflectiveOperationException.class})
@Override
public XAConnection wrap(final XADataSource xaDataSource, final Connection connection) {
MariaDbConnection physicalConnection = (MariaDbConnection) connection.unwrap(Class.forName("org.mariadb.jdbc.MariaDbConnection"));
diff --git a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MySQLXAConnectionWrapper.java b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MySQLXAConnectionWrapper.java
index 63d3773..f98b246 100644
--- a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MySQLXAConnectionWrapper.java
+++ b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MySQLXAConnectionWrapper.java
@@ -25,6 +25,7 @@ import javax.sql.XAConnection;
import javax.sql.XADataSource;
import java.lang.reflect.Method;
import java.sql.Connection;
+import java.sql.SQLException;
/**
* XA connection wrapper for MySQL.
@@ -36,7 +37,7 @@ public final class MySQLXAConnectionWrapper implements XAConnectionWrapper {
private static final String MYSQL_XA_DATASOURCE_8 = "com.mysql.cj.jdbc.MysqlXADataSource";
- @SneakyThrows
+ @SneakyThrows(ReflectiveOperationException.class)
@Override
public XAConnection wrap(final XADataSource xaDataSource, final Connection connection) {
Connection physicalConnection = unwrapPhysicalConnection(xaDataSource.getClass().getName(), connection);
@@ -45,7 +46,7 @@ public final class MySQLXAConnectionWrapper implements XAConnectionWrapper {
return (XAConnection) method.invoke(xaDataSource, physicalConnection);
}
- @SneakyThrows
+ @SneakyThrows({SQLException.class, ClassNotFoundException.class})
private Connection unwrapPhysicalConnection(final String xaDataSourceClassName, final Connection connection) {
switch (xaDataSourceClassName) {
case MYSQL_XA_DATASOURCE_5:
diff --git a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OracleXAConnectionWrapper.java b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OracleXAConnectionWrapper.java
index 19e5b80..9b3838f 100644
--- a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OracleXAConnectionWrapper.java
+++ b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OracleXAConnectionWrapper.java
@@ -25,6 +25,7 @@ import javax.sql.XAConnection;
import javax.sql.XADataSource;
import java.lang.reflect.Constructor;
import java.sql.Connection;
+import java.sql.SQLException;
/**
* XA connection wrapper for Oracle.
@@ -33,7 +34,7 @@ import java.sql.Connection;
public final class OracleXAConnectionWrapper implements XAConnectionWrapper {
@SuppressWarnings("unchecked")
- @SneakyThrows
+ @SneakyThrows({SQLException.class, ReflectiveOperationException.class})
@Override
public XAConnection wrap(final XADataSource xaDataSource, final Connection connection) {
Connection physicalConnection = (Connection) connection.unwrap(Class.forName("oracle.jdbc.internal.OracleConnection"));
diff --git a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/PostgreSQLXAConnectionWrapper.java b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/PostgreSQLXAConnectionWrapper.java
index 859927f..14227d5 100644
--- a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/PostgreSQLXAConnectionWrapper.java
+++ b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/PostgreSQLXAConnectionWrapper.java
@@ -25,13 +25,14 @@ import org.postgresql.xa.PGXAConnection;
import javax.sql.XAConnection;
import javax.sql.XADataSource;
import java.sql.Connection;
+import java.sql.SQLException;
/**
* PostgreSQL XA connection wrapper.
*/
public final class PostgreSQLXAConnectionWrapper implements XAConnectionWrapper {
- @SneakyThrows
+ @SneakyThrows({SQLException.class, ClassNotFoundException.class})
@Override
public XAConnection wrap(final XADataSource xaDataSource, final Connection connection) {
BaseConnection physicalConnection = (BaseConnection) connection.unwrap(Class.forName("org.postgresql.core.BaseConnection"));
diff --git a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-narayana/src/main/java/org/apache/shardingsphere/transaction/xa/narayana/manager/NarayanaXATransactionManager.java b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-narayana/src/main/java/org/apache/shardingsphere/transaction/xa/narayana/manager/NarayanaXATransactionManager.java
index 7be121b..45c53b4 100644
--- a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-narayana/src/main/java/org/apache/shardingsphere/transaction/xa/narayana/manager/NarayanaXATransactionManager.java
+++ b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-narayana/src/main/java/org/apache/shardingsphere/transaction/xa/narayana/manager/NarayanaXATransactionManager.java
@@ -26,6 +26,8 @@ import org.apache.shardingsphere.transaction.xa.spi.SingleXAResource;
import org.apache.shardingsphere.transaction.xa.spi.XATransactionManager;
import javax.sql.XADataSource;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
/**
@@ -56,7 +58,7 @@ public final class NarayanaXATransactionManager implements XATransactionManager
xaRecoveryModule.removeXAResourceRecoveryHelper(new DataSourceXAResourceRecoveryHelper(xaDataSource));
}
- @SneakyThrows
+ @SneakyThrows({SystemException.class, RollbackException.class})
@Override
public void enlistResource(final SingleXAResource singleXAResource) {
transactionManager.getTransaction().enlistResource(singleXAResource.getDelegate());
diff --git a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-narayana/src/test/java/org/apache/shardingsphere/transaction/xa/narayana/manager/NarayanaXATransactionManagerTest.java b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-narayana/src/test/java/org/apache/shardingsphere/transaction/xa/narayana/manager/NarayanaXATransactionManagerTest.java
index b5f64e1..94f1501 100644
--- a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-narayana/src/test/java/org/apache/shardingsphere/transaction/xa/narayana/manager/NarayanaXATransactionManagerTest.java
+++ b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-narayana/src/test/java/org/apache/shardingsphere/transaction/xa/narayana/manager/NarayanaXATransactionManagerTest.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.transaction.xa.narayana.manager;
import com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule;
import com.arjuna.ats.jbossatx.jta.RecoveryManagerService;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.transaction.xa.narayana.manager.fixture.ReflectiveUtil;
import org.apache.shardingsphere.transaction.xa.spi.SingleXAResource;
import org.junit.Before;
@@ -29,6 +28,8 @@ import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import javax.sql.XADataSource;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
@@ -56,7 +57,6 @@ public final class NarayanaXATransactionManagerTest {
@Mock
private XADataSource xaDataSource;
- @SneakyThrows
@Before
public void setUp() {
ReflectiveUtil.setProperty(narayanaXATransactionManager, "xaRecoveryModule", xaRecoveryModule);
@@ -64,7 +64,6 @@ public final class NarayanaXATransactionManagerTest {
ReflectiveUtil.setProperty(narayanaXATransactionManager, "recoveryManagerService", recoveryManagerService);
}
- @SneakyThrows
@Test
public void assertInit() {
narayanaXATransactionManager.init();
@@ -84,9 +83,8 @@ public final class NarayanaXATransactionManagerTest {
verify(xaRecoveryModule).removeXAResourceRecoveryHelper(any(DataSourceXAResourceRecoveryHelper.class));
}
- @SneakyThrows
@Test
- public void assertEnlistResource() {
+ public void assertEnlistResource() throws SystemException, RollbackException {
SingleXAResource singleXAResource = mock(SingleXAResource.class);
Transaction transaction = mock(Transaction.class);
when(transactionManager.getTransaction()).thenReturn(transaction);
@@ -99,9 +97,8 @@ public final class NarayanaXATransactionManagerTest {
assertThat(narayanaXATransactionManager.getTransactionManager(), is(transactionManager));
}
- @SneakyThrows
@Test
- public void assertClose() {
+ public void assertClose() throws Exception {
narayanaXATransactionManager.close();
verify(recoveryManagerService).stop();
verify(recoveryManagerService).destroy();
diff --git a/shardingsphere-transaction/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/main/java/org/apache/shardingsphere/transaction/base/seata/at/SeataATShardingTransactionManager.java b/shardingsphere-transaction/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/main/java/org/apache/shardingsphere/transaction/base/seata/at/SeataATShardingTransactionManager.java
index bd8cf24..ddec873 100644
--- a/shardingsphere-transaction/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/main/java/org/apache/shardingsphere/transaction/base/seata/at/SeataATShardingTransactionManager.java
+++ b/shardingsphere-transaction/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/main/java/org/apache/shardingsphere/transaction/base/seata/at/SeataATShardingTransactionManager.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.transaction.base.seata.at;
import com.google.common.base.Preconditions;
import io.seata.config.FileConfiguration;
import io.seata.core.context.RootContext;
+import io.seata.core.exception.TransactionException;
import io.seata.core.rpc.netty.RmRpcClient;
import io.seata.core.rpc.netty.TmRpcClient;
import io.seata.rm.RMClient;
@@ -94,7 +95,7 @@ public final class SeataATShardingTransactionManager implements ShardingTransact
}
@Override
- @SneakyThrows
+ @SneakyThrows(TransactionException.class)
public void begin() {
Preconditions.checkState(enableSeataAT, "sharding seata-at transaction has been disabled.");
GlobalTransaction globalTransaction = GlobalTransactionContext.getCurrentOrCreate();
@@ -103,7 +104,7 @@ public final class SeataATShardingTransactionManager implements ShardingTransact
}
@Override
- @SneakyThrows
+ @SneakyThrows(TransactionException.class)
public void commit() {
Preconditions.checkState(enableSeataAT, "sharding seata-at transaction has been disabled.");
try {
@@ -115,7 +116,7 @@ public final class SeataATShardingTransactionManager implements ShardingTransact
}
@Override
- @SneakyThrows
+ @SneakyThrows(TransactionException.class)
public void rollback() {
Preconditions.checkState(enableSeataAT, "sharding seata-at transaction has been disabled.");
try {
diff --git a/shardingsphere-transaction/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/test/java/org/apache/shardingsphere/transaction/base/seata/at/SeataATShardingTransactionManagerTest.java b/shardingsphere-transaction/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/test/java/org/apache/shardingsphere/transaction/base/seata/at/SeataATShardingTransactionManagerTest.java
index 5ae2753..b7f1d03 100644
--- a/shardingsphere-transaction/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/test/java/org/apache/shardingsphere/transaction/base/seata/at/SeataATShardingTransactionManagerTest.java
+++ b/shardingsphere-transaction/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/test/java/org/apache/shardingsphere/transaction/base/seata/at/SeataATShardingTransactionManagerTest.java
@@ -47,6 +47,7 @@ import org.mockito.junit.MockitoJUnitRunner;
import javax.sql.DataSource;
import java.lang.reflect.Field;
import java.sql.Connection;
+import java.sql.SQLException;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
@@ -124,8 +125,7 @@ public final class SeataATShardingTransactionManagerTest {
}
@Test
- @SneakyThrows
- public void assertGetConnection() {
+ public void assertGetConnection() throws SQLException {
Connection actual = seataATShardingTransactionManager.getConnection("demo_ds");
assertThat(actual, instanceOf(ConnectionProxy.class));
}
diff --git a/shardingsphere-transaction/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/test/java/org/apache/shardingsphere/transaction/base/seata/at/fixture/MockSeataServer.java b/shardingsphere-transaction/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/test/java/org/apache/shardingsphere/transaction/base/seata/at/fixture/MockSeataServer.java
index 3acf8b6..635dadf 100644
--- a/shardingsphere-transaction/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/test/java/org/apache/shardingsphere/transaction/base/seata/at/fixture/MockSeataServer.java
+++ b/shardingsphere-transaction/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/test/java/org/apache/shardingsphere/transaction/base/seata/at/fixture/MockSeataServer.java
@@ -64,7 +64,7 @@ public final class MockSeataServer {
/**
* start.
*/
- @SneakyThrows
+ @SneakyThrows(InterruptedException.class)
public void start() {
bootstrap.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
@@ -90,7 +90,6 @@ public final class MockSeataServer {
/**
* shutdown.
*/
- @SneakyThrows
public void shutdown() {
if (initialized.get()) {
bossGroup.shutdownGracefully();