You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by su...@apache.org on 2023/05/18 16:15:14 UTC

[shardingsphere] branch master updated: Fix sonar issue of Use "Thread.currentThread().getContextClassLoader()" instead. (#25771)

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

sunnianjun 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 c3db01de852 Fix sonar issue of Use "Thread.currentThread().getContextClassLoader()" instead. (#25771)
c3db01de852 is described below

commit c3db01de8523ecf09848482aafab00d053eba664
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Fri May 19 00:15:05 2023 +0800

    Fix sonar issue of Use "Thread.currentThread().getContextClassLoader()" instead. (#25771)
---
 .../plugin/config/PluginConfigurationLoaderTest.java |  2 +-
 .../swapper/YamlPluginsConfigurationSwapperTest.java | 20 ++++++++++++--------
 .../generator/core/ExampleGeneratorFactory.java      |  2 +-
 .../espresso/EspressoInlineExpressionParser.java     |  2 +-
 .../ShardingSphereYamlConstructorTest.java           |  4 ++--
 .../driver/ShardingSphereDriverURLManagerTest.java   |  2 +-
 .../sqlfederation/optimizer/it/TestCasesLoader.java  |  2 +-
 .../standalone/jdbc/sql/JDBCRepositorySQLLoader.java |  4 ++--
 .../e2e/agent/common/env/EnvironmentProperties.java  |  2 +-
 .../metrics/cases/IntegrationTestCasesLoader.java    |  2 +-
 .../jaeger/cases/IntegrationTestCasesLoader.java     |  2 +-
 .../zipkin/cases/IntegrationTestCasesLoader.java     |  2 +-
 .../test/e2e/driver/AbstractDriverTest.java          |  8 ++++----
 .../test/e2e/driver/AbstractEncryptDriverTest.java   |  4 ++--
 .../driver/AbstractReadwriteSplittingDriverTest.java |  2 +-
 .../test/e2e/driver/AbstractShadowDriverTest.java    |  3 +--
 .../test/e2e/driver/AbstractShardingDriverTest.java  |  4 ++--
 .../e2e/env/runtime/IntegrationTestEnvironment.java  |  2 +-
 .../runtime/scenario/path/ScenarioCommonPath.java    |  4 ++--
 .../env/runtime/scenario/path/ScenarioDataPath.java  |  8 ++++----
 .../pipeline/cases/PipelineContainerComposer.java    |  2 +-
 .../cases/createtable/CreateTableSQLGeneratorIT.java |  2 +-
 .../cases/migration/AbstractMigrationE2EIT.java      |  2 +-
 .../data/pipeline/env/PipelineE2EEnvironment.java    |  2 +-
 .../env/ShowProcessListEnvironment.java              |  2 +-
 .../cases/cursor/OpenGaussCursorTestCase.java        |  2 +-
 .../engine/base/TransactionBaseE2EIT.java            |  2 +-
 .../transaction/env/TransactionE2EEnvironment.java   |  2 +-
 .../container/compose/DockerContainerComposer.java   |  4 ++--
 .../test/e2e/cases/IntegrationTestCasesLoader.java   |  2 +-
 .../engine/scenario/EncryptSQLRewriterIT.java        |  5 ++---
 .../it/rewrite/engine/scenario/MixSQLRewriterIT.java |  5 ++---
 .../engine/scenario/ShardingSQLRewriterIT.java       |  5 ++---
 .../loader/RewriteAssertionsRootEntityLoader.java    |  2 +-
 34 files changed, 60 insertions(+), 60 deletions(-)

diff --git a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/config/PluginConfigurationLoaderTest.java b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/config/PluginConfigurationLoaderTest.java
index b85fd4fa4df..3e7ec100c51 100644
--- a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/config/PluginConfigurationLoaderTest.java
+++ b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/config/PluginConfigurationLoaderTest.java
@@ -43,7 +43,7 @@ class PluginConfigurationLoaderTest {
     }
     
     private String getResourceURL() throws UnsupportedEncodingException {
-        return URLDecoder.decode(Objects.requireNonNull(PluginConfigurationLoader.class.getClassLoader().getResource("")).getFile(), "UTF8");
+        return URLDecoder.decode(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource("")).getFile(), "UTF8");
     }
     
     private void assertLoggingPluginConfiguration(final PluginConfiguration actual) {
diff --git a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/config/yaml/swapper/YamlPluginsConfigurationSwapperTest.java b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/config/yaml/swapper/YamlPluginsConfigurationSwapperTest.java
index 3bb953f64d9..01177763206 100644
--- a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/config/yaml/swapper/YamlPluginsConfigurationSwapperTest.java
+++ b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/config/yaml/swapper/YamlPluginsConfigurationSwapperTest.java
@@ -25,12 +25,14 @@ import org.apache.shardingsphere.agent.core.yaml.AgentYamlEngine;
 import org.junit.jupiter.api.Test;
 
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
+import java.nio.file.Files;
 import java.util.Collections;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
@@ -81,16 +83,18 @@ class YamlPluginsConfigurationSwapperTest {
     
     @Test
     void assertSwapWithFile() throws IOException {
-        YamlAgentConfiguration yamlAgentConfig = AgentYamlEngine.unmarshalYamlAgentConfiguration(new FileInputStream(new File(getResourceURL(), CONFIG_PATH)));
-        Map<String, PluginConfiguration> actual = YamlPluginsConfigurationSwapper.swap(yamlAgentConfig);
-        assertThat(actual.size(), is(3));
-        assertLogFixturePluginConfiguration(actual.get("log_fixture"));
-        assertMetricsPluginConfiguration(actual.get("metrics_fixture"));
-        assertTracingPluginConfiguration(actual.get("tracing_fixture"));
+        try (InputStream inputStream = Files.newInputStream(new File(getResourceURL(), CONFIG_PATH).toPath())) {
+            YamlAgentConfiguration yamlAgentConfig = AgentYamlEngine.unmarshalYamlAgentConfiguration(inputStream);
+            Map<String, PluginConfiguration> actual = YamlPluginsConfigurationSwapper.swap(yamlAgentConfig);
+            assertThat(actual.size(), is(3));
+            assertLogFixturePluginConfiguration(actual.get("log_fixture"));
+            assertMetricsPluginConfiguration(actual.get("metrics_fixture"));
+            assertTracingPluginConfiguration(actual.get("tracing_fixture"));
+        }
     }
     
     private String getResourceURL() throws UnsupportedEncodingException {
-        return URLDecoder.decode(YamlPluginsConfigurationSwapper.class.getClassLoader().getResource("").getFile(), "UTF8");
+        return URLDecoder.decode(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource("")).getFile(), "UTF8");
     }
     
     private void assertLogFixturePluginConfiguration(final PluginConfiguration actual) {
diff --git a/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/ExampleGeneratorFactory.java b/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/ExampleGeneratorFactory.java
index 9d8f15ecc53..9af38a049ee 100644
--- a/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/ExampleGeneratorFactory.java
+++ b/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/ExampleGeneratorFactory.java
@@ -49,7 +49,7 @@ public final class ExampleGeneratorFactory {
     
     private Configuration createTemplateConfiguration() throws IOException {
         Configuration result = new Configuration(Configuration.VERSION_2_3_31);
-        result.setDirectoryForTemplateLoading(new File(Objects.requireNonNull(ExampleGeneratorFactory.class.getClassLoader().getResource("template")).getFile()));
+        result.setDirectoryForTemplateLoading(new File(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource("template")).getFile()));
         result.setDefaultEncoding("UTF-8");
         return result;
     }
diff --git a/infra/expr/espresso/src/main/java/org/apache/shardingsphere/infra/expr/espresso/EspressoInlineExpressionParser.java b/infra/expr/espresso/src/main/java/org/apache/shardingsphere/infra/expr/espresso/EspressoInlineExpressionParser.java
index 811f79bf612..d1360b3636a 100644
--- a/infra/expr/espresso/src/main/java/org/apache/shardingsphere/infra/expr/espresso/EspressoInlineExpressionParser.java
+++ b/infra/expr/espresso/src/main/java/org/apache/shardingsphere/infra/expr/espresso/EspressoInlineExpressionParser.java
@@ -43,7 +43,7 @@ public final class EspressoInlineExpressionParser implements InlineExpressionPar
     
     static {
         JAVA_HOME = System.getenv("JAVA_HOME");
-        URL resource = EspressoInlineExpressionParser.class.getClassLoader().getResource("espresso-need-libs");
+        URL resource = Thread.currentThread().getContextClassLoader().getResource("espresso-need-libs");
         String dir = null != resource ? resource.getPath() : null;
         JAVA_CLASSPATH = Stream.of("groovy.jar", "guava.jar", "shardingsphere-infra-expr-hotsopt.jar", "shardingsphere-infra-expr-spi.jar", "shardingsphere-infra-util.jar")
                 .map(each -> dir + File.separator + each).collect(Collectors.joining(":"));
diff --git a/infra/util/src/test/java/org/apache/shardingsphere/infra/util/yaml/constructor/ShardingSphereYamlConstructorTest.java b/infra/util/src/test/java/org/apache/shardingsphere/infra/util/yaml/constructor/ShardingSphereYamlConstructorTest.java
index 25f375740ed..6a1ea128618 100644
--- a/infra/util/src/test/java/org/apache/shardingsphere/infra/util/yaml/constructor/ShardingSphereYamlConstructorTest.java
+++ b/infra/util/src/test/java/org/apache/shardingsphere/infra/util/yaml/constructor/ShardingSphereYamlConstructorTest.java
@@ -35,7 +35,7 @@ class ShardingSphereYamlConstructorTest {
     
     @Test
     void assertToObject() throws IOException {
-        try (InputStream inputStream = ShardingSphereYamlConstructorTest.class.getClassLoader().getResourceAsStream("yaml/customized-obj.yaml")) {
+        try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("yaml/customized-obj.yaml")) {
             assertYamlObject(new Yaml(new ShardingSphereYamlConstructor(YamlConfigurationFixture.class)).loadAs(inputStream, YamlConfigurationFixture.class));
         }
     }
@@ -52,7 +52,7 @@ class ShardingSphereYamlConstructorTest {
     
     @Test
     void assertToObjectWithNotAcceptClass() throws IOException {
-        try (InputStream inputStream = ShardingSphereYamlConstructorTest.class.getClassLoader().getResourceAsStream("yaml/accepted-class.yaml")) {
+        try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("yaml/accepted-class.yaml")) {
             assertThrows(ConstructorException.class, () -> new Yaml(new ShardingSphereYamlConstructor(Object.class)).loadAs(inputStream, Object.class));
         }
     }
diff --git a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/driver/ShardingSphereDriverURLManagerTest.java b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/driver/ShardingSphereDriverURLManagerTest.java
index 4ed977413ba..d07e5810357 100644
--- a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/driver/ShardingSphereDriverURLManagerTest.java
+++ b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/driver/ShardingSphereDriverURLManagerTest.java
@@ -56,7 +56,7 @@ class ShardingSphereDriverURLManagerTest {
     
     @Test
     void assertToAbsolutePathConfigurationFile() {
-        String absolutePath = Objects.requireNonNull(ShardingSphereDriverURLManagerTest.class.getClassLoader().getResource("config/driver/foo-driver-fixture.yaml")).getPath();
+        String absolutePath = Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource("config/driver/foo-driver-fixture.yaml")).getPath();
         byte[] actual = ShardingSphereDriverURLManager.getContent("jdbc:shardingsphere:absolutepath:" + absolutePath);
         assertThat(actual.length, is(fooDriverConfigLength));
     }
diff --git a/kernel/sql-federation/optimizer/src/test/java/org/apache/shardingsphere/sqlfederation/optimizer/it/TestCasesLoader.java b/kernel/sql-federation/optimizer/src/test/java/org/apache/shardingsphere/sqlfederation/optimizer/it/TestCasesLoader.java
index 8b76c3b1a57..3b10c44681e 100644
--- a/kernel/sql-federation/optimizer/src/test/java/org/apache/shardingsphere/sqlfederation/optimizer/it/TestCasesLoader.java
+++ b/kernel/sql-federation/optimizer/src/test/java/org/apache/shardingsphere/sqlfederation/optimizer/it/TestCasesLoader.java
@@ -49,7 +49,7 @@ public final class TestCasesLoader {
      * @throws JAXBException exception for parse xml file.
      */
     public Collection<TestCase> generate() throws IOException, JAXBException {
-        URL url = Objects.requireNonNull(TestCasesLoader.class.getClassLoader().getResource("cases/federation-query-sql-cases.xml"));
+        URL url = Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource("cases/federation-query-sql-cases.xml"));
         try (FileReader reader = new FileReader(url.getFile())) {
             TestCases testCases = (TestCases) JAXBContext.newInstance(TestCases.class).createUnmarshaller().unmarshal(reader);
             return testCases.getTestCases();
diff --git a/mode/type/standalone/repository/provider/jdbc/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/sql/JDBCRepositorySQLLoader.java b/mode/type/standalone/repository/provider/jdbc/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/sql/JDBCRepositorySQLLoader.java
index 8cd26deb003..fd5bb782e4c 100644
--- a/mode/type/standalone/repository/provider/jdbc/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/sql/JDBCRepositorySQLLoader.java
+++ b/mode/type/standalone/repository/provider/jdbc/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/sql/JDBCRepositorySQLLoader.java
@@ -62,7 +62,7 @@ public final class JDBCRepositorySQLLoader {
     }
     
     private static JDBCRepositorySQL loadFromDirectory(final String type) throws URISyntaxException, IOException {
-        Enumeration<URL> urls = JDBCRepositorySQLLoader.class.getClassLoader().getResources(ROOT_DIRECTORY);
+        Enumeration<URL> urls = Thread.currentThread().getContextClassLoader().getResources(ROOT_DIRECTORY);
         if (null == urls) {
             return null;
         }
@@ -106,7 +106,7 @@ public final class JDBCRepositorySQLLoader {
                 if (!name.startsWith(ROOT_DIRECTORY) || !name.endsWith(FILE_EXTENSION)) {
                     continue;
                 }
-                final InputStream inputStream = JDBCRepositorySQLLoader.class.getClassLoader().getResourceAsStream(name);
+                final InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
                 JDBCRepositorySQL provider = (JDBCRepositorySQL) JAXBContext.newInstance(JDBCRepositorySQL.class).createUnmarshaller().unmarshal(inputStream);
                 if (Objects.equals(provider.isDefault(), true)) {
                     defaultProvider = provider;
diff --git a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/env/EnvironmentProperties.java b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/env/EnvironmentProperties.java
index c63ff842ba4..42bc17c9246 100644
--- a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/env/EnvironmentProperties.java
+++ b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/env/EnvironmentProperties.java
@@ -40,7 +40,7 @@ public final class EnvironmentProperties {
     @SuppressWarnings("AccessOfSystemProperties")
     public static Properties loadProperties(final String propsFileName) {
         Properties result = new Properties();
-        try (InputStream inputStream = EnvironmentProperties.class.getClassLoader().getResourceAsStream(propsFileName)) {
+        try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(propsFileName)) {
             result.load(inputStream);
         } catch (final IOException ex) {
             throw new RuntimeException(ex);
diff --git a/test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/cases/IntegrationTestCasesLoader.java b/test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/cases/IntegrationTestCasesLoader.java
index 599ea80f54e..4197194284f 100644
--- a/test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/cases/IntegrationTestCasesLoader.java
+++ b/test/e2e/agent/plugins/metrics/prometheus/src/test/java/org/apache/shardingsphere/test/e2e/agent/metrics/cases/IntegrationTestCasesLoader.java
@@ -71,7 +71,7 @@ public final class IntegrationTestCasesLoader {
             return integrationTestCases;
         }
         integrationTestCases = new LinkedList<>();
-        URL url = Objects.requireNonNull(IntegrationTestCasesLoader.class.getClassLoader().getResource(String.format("cases/%s", adapter)));
+        URL url = Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource(String.format("cases/%s", adapter)));
         Collection<File> files = getFiles(url);
         for (File each : files) {
             integrationTestCases.addAll(unmarshal(each.getPath()).getTestCases());
diff --git a/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/cases/IntegrationTestCasesLoader.java b/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/cases/IntegrationTestCasesLoader.java
index 2141ae657bc..f4db4ba826f 100644
--- a/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/cases/IntegrationTestCasesLoader.java
+++ b/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/cases/IntegrationTestCasesLoader.java
@@ -71,7 +71,7 @@ public final class IntegrationTestCasesLoader {
             return integrationTestCases;
         }
         integrationTestCases = new LinkedList<>();
-        URL url = Objects.requireNonNull(IntegrationTestCasesLoader.class.getClassLoader().getResource(String.format("cases/%s", adapter)));
+        URL url = Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource(String.format("cases/%s", adapter)));
         Collection<File> files = getFiles(url);
         for (File each : files) {
             integrationTestCases.addAll(unmarshal(each.getPath()).getTestCases());
diff --git a/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/cases/IntegrationTestCasesLoader.java b/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/cases/IntegrationTestCasesLoader.java
index 3bfbf853df0..bf28f3aa2a0 100644
--- a/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/cases/IntegrationTestCasesLoader.java
+++ b/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/cases/IntegrationTestCasesLoader.java
@@ -70,7 +70,7 @@ public final class IntegrationTestCasesLoader {
             return integrationTestCases;
         }
         integrationTestCases = new LinkedList<>();
-        URL url = Objects.requireNonNull(IntegrationTestCasesLoader.class.getClassLoader().getResource(String.format("cases/%s", adapter)));
+        URL url = Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource(String.format("cases/%s", adapter)));
         Collection<File> files = getFiles(url);
         for (File each : files) {
             integrationTestCases.addAll(unmarshal(each.getPath()).getTestCases());
diff --git a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractDriverTest.java b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractDriverTest.java
index e470a73d1cc..f67efa2ddf4 100644
--- a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractDriverTest.java
+++ b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractDriverTest.java
@@ -49,13 +49,13 @@ public abstract class AbstractDriverTest {
     private static void initializeSchema(final String dataSourceName) throws SQLException {
         try (Connection connection = ACTUAL_DATA_SOURCES.get(dataSourceName).getConnection()) {
             if ("encrypt".equals(dataSourceName)) {
-                RunScript.execute(connection, new InputStreamReader(Objects.requireNonNull(AbstractDriverTest.class.getClassLoader().getResourceAsStream("sql/jdbc_encrypt_init.sql"))));
+                RunScript.execute(connection, new InputStreamReader(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResourceAsStream("sql/jdbc_encrypt_init.sql"))));
             } else if ("shadow_jdbc_0".equals(dataSourceName) || "shadow_jdbc_1".equals(dataSourceName)) {
-                RunScript.execute(connection, new InputStreamReader(Objects.requireNonNull(AbstractDriverTest.class.getClassLoader().getResourceAsStream("sql/jdbc_shadow_init.sql"))));
+                RunScript.execute(connection, new InputStreamReader(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResourceAsStream("sql/jdbc_shadow_init.sql"))));
             } else if ("single_jdbc".equals(dataSourceName)) {
-                RunScript.execute(connection, new InputStreamReader(Objects.requireNonNull(AbstractDriverTest.class.getClassLoader().getResourceAsStream("sql/single_jdbc_init.sql"))));
+                RunScript.execute(connection, new InputStreamReader(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResourceAsStream("sql/single_jdbc_init.sql"))));
             } else {
-                RunScript.execute(connection, new InputStreamReader(Objects.requireNonNull(AbstractDriverTest.class.getClassLoader().getResourceAsStream("sql/jdbc_init.sql"))));
+                RunScript.execute(connection, new InputStreamReader(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResourceAsStream("sql/jdbc_init.sql"))));
             }
         }
     }
diff --git a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractEncryptDriverTest.java b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractEncryptDriverTest.java
index 0a2ac38cf3b..336bc5c0132 100644
--- a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractEncryptDriverTest.java
+++ b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractEncryptDriverTest.java
@@ -57,7 +57,7 @@ public abstract class AbstractEncryptDriverTest extends AbstractDriverTest {
     
     private static File getFile(final String fileName) {
         return new File(Objects.requireNonNull(
-                AbstractEncryptDriverTest.class.getClassLoader().getResource(fileName), String.format("File `%s` is not existed.", fileName)).getFile());
+                Thread.currentThread().getContextClassLoader().getResource(fileName), String.format("File `%s` is not existed.", fileName)).getFile());
     }
     
     private static Map<String, DataSource> getDataSourceMap() {
@@ -67,7 +67,7 @@ public abstract class AbstractEncryptDriverTest extends AbstractDriverTest {
     @BeforeEach
     void initTable() {
         try (Connection connection = queryWithCipherDataSource.getConnection()) {
-            RunScript.execute(connection, new InputStreamReader(Objects.requireNonNull(AbstractDriverTest.class.getClassLoader().getResourceAsStream("sql/encrypt_data.sql"))));
+            RunScript.execute(connection, new InputStreamReader(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResourceAsStream("sql/encrypt_data.sql"))));
         } catch (final SQLException ex) {
             throw new RuntimeException(ex);
         }
diff --git a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractReadwriteSplittingDriverTest.java b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractReadwriteSplittingDriverTest.java
index 9e4ddc8e3d3..fc82536a73e 100644
--- a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractReadwriteSplittingDriverTest.java
+++ b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractReadwriteSplittingDriverTest.java
@@ -54,7 +54,7 @@ public abstract class AbstractReadwriteSplittingDriverTest extends AbstractDrive
     
     private static File getFile() {
         return new File(Objects.requireNonNull(
-                AbstractReadwriteSplittingDriverTest.class.getClassLoader().getResource(CONFIG_FILE), String.format("File `%s` is not existed.", CONFIG_FILE)).getFile());
+                Thread.currentThread().getContextClassLoader().getResource(CONFIG_FILE), String.format("File `%s` is not existed.", CONFIG_FILE)).getFile());
     }
     
     protected final ShardingSphereDataSource getReadwriteSplittingDataSource() {
diff --git a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractShadowDriverTest.java b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractShadowDriverTest.java
index d03b0af04d0..889b5d0e56d 100644
--- a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractShadowDriverTest.java
+++ b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractShadowDriverTest.java
@@ -53,8 +53,7 @@ public abstract class AbstractShadowDriverTest extends AbstractDriverTest {
     }
     
     private static File getFile() {
-        return new File(Objects.requireNonNull(
-                AbstractShadowDriverTest.class.getClassLoader().getResource(CONFIG_FILE), String.format("File `%s` is not existed.", CONFIG_FILE)).getFile());
+        return new File(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource(CONFIG_FILE), String.format("File `%s` is not existed.", CONFIG_FILE)).getFile());
     }
     
     protected final ShardingSphereDataSource getShadowDataSource() {
diff --git a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractShardingDriverTest.java b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractShardingDriverTest.java
index 406027b70c9..e3f8f7b0cf1 100644
--- a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractShardingDriverTest.java
+++ b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractShardingDriverTest.java
@@ -58,14 +58,14 @@ public abstract class AbstractShardingDriverTest extends AbstractDriverTest {
     
     private static File getFile() {
         return new File(Objects.requireNonNull(
-                AbstractShardingDriverTest.class.getClassLoader().getResource(CONFIG_FILE), String.format("File `%s` is not existed.", CONFIG_FILE)).getFile());
+                Thread.currentThread().getContextClassLoader().getResource(CONFIG_FILE), String.format("File `%s` is not existed.", CONFIG_FILE)).getFile());
     }
     
     @BeforeEach
     void initTable() {
         try {
             Connection connection = dataSource.getConnection();
-            RunScript.execute(connection, new InputStreamReader(Objects.requireNonNull(AbstractDriverTest.class.getClassLoader().getResourceAsStream("sql/jdbc_data.sql"))));
+            RunScript.execute(connection, new InputStreamReader(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResourceAsStream("sql/jdbc_data.sql"))));
             connection.close();
         } catch (final SQLException ex) {
             throw new RuntimeException(ex);
diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/IntegrationTestEnvironment.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/IntegrationTestEnvironment.java
index aad2ae66b79..cfacdf51297 100644
--- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/IntegrationTestEnvironment.java
+++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/IntegrationTestEnvironment.java
@@ -54,7 +54,7 @@ public final class IntegrationTestEnvironment {
     @SuppressWarnings("AccessOfSystemProperties")
     private Properties loadProperties() {
         Properties result = new Properties();
-        try (InputStream inputStream = IntegrationTestEnvironment.class.getClassLoader().getResourceAsStream("env/it-env.properties")) {
+        try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("env/it-env.properties")) {
             result.load(inputStream);
         } catch (final IOException ex) {
             throw new RuntimeException(ex);
diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/scenario/path/ScenarioCommonPath.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/scenario/path/ScenarioCommonPath.java
index a503776af67..54a58da920b 100644
--- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/scenario/path/ScenarioCommonPath.java
+++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/scenario/path/ScenarioCommonPath.java
@@ -42,7 +42,7 @@ public final class ScenarioCommonPath {
      */
     public void checkFolderExist() {
         String scenarioDirectory = String.join("/", ROOT_PATH, scenario);
-        assertNotNull(ScenarioCommonPath.class.getClassLoader().getResource(scenarioDirectory), String.format("Scenario folder `%s` must exist.", scenarioDirectory));
+        assertNotNull(Thread.currentThread().getContextClassLoader().getResource(scenarioDirectory), String.format("Scenario folder `%s` must exist.", scenarioDirectory));
     }
     
     /**
@@ -65,7 +65,7 @@ public final class ScenarioCommonPath {
     
     private String getFile(final String fileName) {
         String path = String.join("/", ROOT_PATH, scenario, fileName);
-        URL url = ScenarioCommonPath.class.getClassLoader().getResource(path);
+        URL url = Thread.currentThread().getContextClassLoader().getResource(path);
         assertNotNull(url, String.format("File `%s` must exist.", path));
         return url.getFile();
     }
diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/scenario/path/ScenarioDataPath.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/scenario/path/ScenarioDataPath.java
index c8605a8ac21..c0f944fe5bf 100644
--- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/scenario/path/ScenarioDataPath.java
+++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/scenario/path/ScenarioDataPath.java
@@ -67,7 +67,7 @@ public final class ScenarioDataPath {
     
     private String getFile(final Type type, final String fileName) {
         String path = String.join("/", getBasicPath(type), fileName);
-        URL url = ScenarioDataPath.class.getClassLoader().getResource(path);
+        URL url = Thread.currentThread().getContextClassLoader().getResource(path);
         assertNotNull(url, String.format("File `%s` must exist.", path));
         return url.getFile();
     }
@@ -82,7 +82,7 @@ public final class ScenarioDataPath {
     public String getInitSQLFile(final Type type, final DatabaseType databaseType) {
         String initSQLFileName = String.join("-", "01", type.name().toLowerCase(), BASIC_INIT_SQL_FILE);
         String initSQLResourceFile = String.join("/", getInitSQLResourcePath(type, databaseType), initSQLFileName);
-        URL url = ScenarioDataPath.class.getClassLoader().getResource(initSQLResourceFile);
+        URL url = Thread.currentThread().getContextClassLoader().getResource(initSQLResourceFile);
         assertNotNull(url, String.format("File `%s` must exist.", initSQLResourceFile));
         return url.getFile();
     }
@@ -100,7 +100,7 @@ public final class ScenarioDataPath {
     
     private boolean isActualDatabaseInitSQLFileExisted(final String databaseName, final DatabaseType databaseType) {
         String initSQLResourceFile = getActualDatabaseInitSQLResourceFile(databaseName, databaseType);
-        return null != ScenarioDataPath.class.getClassLoader().getResource(initSQLResourceFile);
+        return null != Thread.currentThread().getContextClassLoader().getResource(initSQLResourceFile);
     }
     
     private String getActualDatabaseInitSQLResourceFile(final String databaseName, final DatabaseType databaseType) {
@@ -110,7 +110,7 @@ public final class ScenarioDataPath {
     
     private String getActualDatabaseInitSQLFile(final String databaseName, final DatabaseType databaseType) {
         String resourceFile = getActualDatabaseInitSQLResourceFile(databaseName, databaseType);
-        URL url = ScenarioDataPath.class.getClassLoader().getResource(resourceFile);
+        URL url = Thread.currentThread().getContextClassLoader().getResource(resourceFile);
         assertNotNull(url, String.format("File `%s` must exist.", resourceFile));
         return url.getFile();
     }
diff --git a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/PipelineContainerComposer.java b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/PipelineContainerComposer.java
index 99a8fb2fe11..8e1487972cc 100644
--- a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/PipelineContainerComposer.java
+++ b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/PipelineContainerComposer.java
@@ -121,7 +121,7 @@ public final class PipelineContainerComposer implements AutoCloseable {
             username = PipelineE2EEnvironment.getInstance().getActualDataSourceUsername(databaseType);
             password = PipelineE2EEnvironment.getInstance().getActualDataSourcePassword(databaseType);
         }
-        extraSQLCommand = JAXB.unmarshal(Objects.requireNonNull(PipelineContainerComposer.class.getClassLoader().getResource(testParam.getScenario())), ExtraSQLCommand.class);
+        extraSQLCommand = JAXB.unmarshal(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource(testParam.getScenario())), ExtraSQLCommand.class);
         containerComposer.start();
         sourceDataSource = StorageContainerUtils.generateDataSource(getActualJdbcUrlTemplate(DS_0, false), username, password);
         proxyDataSource = StorageContainerUtils.generateDataSource(
diff --git a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/createtable/CreateTableSQLGeneratorIT.java b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/createtable/CreateTableSQLGeneratorIT.java
index 65534fa7b15..a68f9061593 100644
--- a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/createtable/CreateTableSQLGeneratorIT.java
+++ b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/createtable/CreateTableSQLGeneratorIT.java
@@ -85,7 +85,7 @@ class CreateTableSQLGeneratorIT {
     void assertGenerateCreateTableSQL(final PipelineTestParameter testParam) throws SQLException {
         startStorageContainer(testParam.getDatabaseType(), testParam.getStorageContainerImage());
         CreateTableSQLGeneratorAssertionsRootEntity rootEntity = JAXB.unmarshal(
-                Objects.requireNonNull(CreateTableSQLGeneratorIT.class.getClassLoader().getResource(testParam.getScenario())), CreateTableSQLGeneratorAssertionsRootEntity.class);
+                Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource(testParam.getScenario())), CreateTableSQLGeneratorAssertionsRootEntity.class);
         DataSource dataSource = storageContainer.createAccessDataSource(DEFAULT_DATABASE);
         try (
                 Connection connection = dataSource.getConnection();
diff --git a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/migration/AbstractMigrationE2EIT.java b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/migration/AbstractMigrationE2EIT.java
index 60d7960e9ed..ebfa6b4f2cd 100644
--- a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/migration/AbstractMigrationE2EIT.java
+++ b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/migration/AbstractMigrationE2EIT.java
@@ -48,7 +48,7 @@ public abstract class AbstractMigrationE2EIT {
     private final MigrationDistSQLCommand migrationDistSQL;
     
     protected AbstractMigrationE2EIT() {
-        migrationDistSQL = JAXB.unmarshal(Objects.requireNonNull(AbstractMigrationE2EIT.class.getClassLoader().getResource("env/common/migration-command.xml")), MigrationDistSQLCommand.class);
+        migrationDistSQL = JAXB.unmarshal(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource("env/common/migration-command.xml")), MigrationDistSQLCommand.class);
     }
     
     protected void addMigrationSourceResource(final PipelineContainerComposer containerComposer) throws SQLException {
diff --git a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/env/PipelineE2EEnvironment.java b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/env/PipelineE2EEnvironment.java
index 36eac3df0c1..2cab6b44381 100644
--- a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/env/PipelineE2EEnvironment.java
+++ b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/env/PipelineE2EEnvironment.java
@@ -60,7 +60,7 @@ public final class PipelineE2EEnvironment {
     @SneakyThrows(IOException.class)
     private Properties loadProperties() {
         Properties result = new Properties();
-        try (InputStream inputStream = PipelineE2EEnvironment.class.getClassLoader().getResourceAsStream("env/it-env.properties")) {
+        try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("env/it-env.properties")) {
             result.load(inputStream);
         }
         for (String each : System.getProperties().stringPropertyNames()) {
diff --git a/test/e2e/operation/showprocesslist/src/test/java/org/apache/shardingsphere/test/e2e/showprocesslist/env/ShowProcessListEnvironment.java b/test/e2e/operation/showprocesslist/src/test/java/org/apache/shardingsphere/test/e2e/showprocesslist/env/ShowProcessListEnvironment.java
index ec2c5618a35..dbc99c9b6ce 100644
--- a/test/e2e/operation/showprocesslist/src/test/java/org/apache/shardingsphere/test/e2e/showprocesslist/env/ShowProcessListEnvironment.java
+++ b/test/e2e/operation/showprocesslist/src/test/java/org/apache/shardingsphere/test/e2e/showprocesslist/env/ShowProcessListEnvironment.java
@@ -63,7 +63,7 @@ public final class ShowProcessListEnvironment {
     @SneakyThrows(IOException.class)
     private Properties loadProperties() {
         Properties result = new Properties();
-        try (InputStream inputStream = ShowProcessListEnvironment.class.getClassLoader().getResourceAsStream("env/it-env.properties")) {
+        try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("env/it-env.properties")) {
             result.load(inputStream);
         }
         for (String each : System.getProperties().stringPropertyNames()) {
diff --git a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/cases/cursor/OpenGaussCursorTestCase.java b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/cases/cursor/OpenGaussCursorTestCase.java
index 8d58c750be0..aee0f46ca2e 100644
--- a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/cases/cursor/OpenGaussCursorTestCase.java
+++ b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/cases/cursor/OpenGaussCursorTestCase.java
@@ -52,7 +52,7 @@ public final class OpenGaussCursorTestCase extends BaseTransactionTestCase {
     }
     
     private CursorSQLCommand loadCursorSQLCommand() {
-        return JAXB.unmarshal(Objects.requireNonNull(TransactionBaseE2EIT.class.getClassLoader().getResource("env/common/cursor-command.xml")), CursorSQLCommand.class);
+        return JAXB.unmarshal(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource("env/common/cursor-command.xml")), CursorSQLCommand.class);
     }
     
     @Override
diff --git a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/engine/base/TransactionBaseE2EIT.java b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/engine/base/TransactionBaseE2EIT.java
index 2a0672255af..dc6c0448993 100644
--- a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/engine/base/TransactionBaseE2EIT.java
+++ b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/engine/base/TransactionBaseE2EIT.java
@@ -86,7 +86,7 @@ public abstract class TransactionBaseE2EIT {
     }
     
     private CommonSQLCommand loadCommonSQLCommand() {
-        return JAXB.unmarshal(Objects.requireNonNull(TransactionBaseE2EIT.class.getClassLoader().getResource("env/common/command.xml")), CommonSQLCommand.class);
+        return JAXB.unmarshal(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource("env/common/command.xml")), CommonSQLCommand.class);
     }
     
     @ParameterizedTest(name = "{0}")
diff --git a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/env/TransactionE2EEnvironment.java b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/env/TransactionE2EEnvironment.java
index aaa14527008..36355a4eca6 100644
--- a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/env/TransactionE2EEnvironment.java
+++ b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/env/TransactionE2EEnvironment.java
@@ -89,7 +89,7 @@ public final class TransactionE2EEnvironment {
     
     private Properties loadProperties() {
         Properties result = new Properties();
-        try (InputStream inputStream = TransactionE2EEnvironment.class.getClassLoader().getResourceAsStream("env/it-env.properties")) {
+        try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("env/it-env.properties")) {
             result.load(inputStream);
         } catch (final IOException ex) {
             throw new RuntimeException(ex);
diff --git a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/compose/DockerContainerComposer.java b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/compose/DockerContainerComposer.java
index 866a9f58049..ee3b4c56d2b 100644
--- a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/compose/DockerContainerComposer.java
+++ b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/compose/DockerContainerComposer.java
@@ -76,11 +76,11 @@ public final class DockerContainerComposer extends BaseContainerComposer {
     }
     
     private URL getShardingSphereConfigResource(final TransactionTestParameter testParam) {
-        URL result = ShardingSphereJDBCContainer.class.getClassLoader().getResource(getScenarioResource(testParam));
+        URL result = Thread.currentThread().getContextClassLoader().getResource(getScenarioResource(testParam));
         if (null != result) {
             return result;
         }
-        result = ShardingSphereJDBCContainer.class.getClassLoader().getResource(getDefaultResource(testParam));
+        result = Thread.currentThread().getContextClassLoader().getResource(getDefaultResource(testParam));
         log.info("Transaction IT tests use the configuration file: {}", result);
         return result;
     }
diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/cases/IntegrationTestCasesLoader.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/cases/IntegrationTestCasesLoader.java
index db5a3f301c0..fb05220604a 100644
--- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/cases/IntegrationTestCasesLoader.java
+++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/cases/IntegrationTestCasesLoader.java
@@ -72,7 +72,7 @@ public final class IntegrationTestCasesLoader {
     
     @SneakyThrows({IOException.class, URISyntaxException.class, JAXBException.class})
     private Collection<IntegrationTestCaseContext> loadIntegrationTestCaseContexts(final SQLCommandType sqlCommandType) {
-        URL url = Objects.requireNonNull(IntegrationTestCasesLoader.class.getClassLoader().getResource("cases/"));
+        URL url = Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource("cases/"));
         return loadIntegrationTestCaseContexts(url, sqlCommandType);
     }
     
diff --git a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/engine/scenario/EncryptSQLRewriterIT.java b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/engine/scenario/EncryptSQLRewriterIT.java
index 96a84a89b9e..1ad26d24261 100644
--- a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/engine/scenario/EncryptSQLRewriterIT.java
+++ b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/engine/scenario/EncryptSQLRewriterIT.java
@@ -17,7 +17,6 @@
 
 package org.apache.shardingsphere.test.it.rewrite.engine.scenario;
 
-import com.google.common.base.Preconditions;
 import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
 import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
 import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
@@ -44,6 +43,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Objects;
 import java.util.Optional;
 
 import static org.mockito.ArgumentMatchers.anyInt;
@@ -56,8 +56,7 @@ class EncryptSQLRewriterIT extends SQLRewriterIT {
     
     @Override
     protected YamlRootConfiguration createRootConfiguration(final SQLRewriteEngineTestParameters testParams) throws IOException {
-        URL url = EncryptSQLRewriterIT.class.getClassLoader().getResource(testParams.getRuleFile());
-        Preconditions.checkNotNull(url, "Can not find rewrite rule yaml configuration");
+        URL url = Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource(testParams.getRuleFile()), "Can not find rewrite rule yaml configuration");
         return YamlEngine.unmarshal(new File(url.getFile()), YamlRootConfiguration.class);
     }
     
diff --git a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/engine/scenario/MixSQLRewriterIT.java b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/engine/scenario/MixSQLRewriterIT.java
index 2993ea70b19..3c16a368360 100644
--- a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/engine/scenario/MixSQLRewriterIT.java
+++ b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/engine/scenario/MixSQLRewriterIT.java
@@ -17,7 +17,6 @@
 
 package org.apache.shardingsphere.test.it.rewrite.engine.scenario;
 
-import com.google.common.base.Preconditions;
 import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereColumn;
 import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereIndex;
 import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
@@ -40,6 +39,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.LinkedList;
 import java.util.Map;
+import java.util.Objects;
 
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -49,8 +49,7 @@ class MixSQLRewriterIT extends SQLRewriterIT {
     
     @Override
     protected YamlRootConfiguration createRootConfiguration(final SQLRewriteEngineTestParameters testParams) throws IOException {
-        URL url = MixSQLRewriterIT.class.getClassLoader().getResource(testParams.getRuleFile());
-        Preconditions.checkNotNull(url, "Can not find rewrite rule yaml configurations");
+        URL url = Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource(testParams.getRuleFile()), "Can not find rewrite rule yaml configurations");
         return YamlEngine.unmarshal(new File(url.getFile()), YamlRootConfiguration.class);
     }
     
diff --git a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/engine/scenario/ShardingSQLRewriterIT.java b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/engine/scenario/ShardingSQLRewriterIT.java
index 963018ba8b1..807202a09c4 100644
--- a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/engine/scenario/ShardingSQLRewriterIT.java
+++ b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/engine/scenario/ShardingSQLRewriterIT.java
@@ -17,7 +17,6 @@
 
 package org.apache.shardingsphere.test.it.rewrite.engine.scenario;
 
-import com.google.common.base.Preconditions;
 import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereColumn;
 import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereIndex;
 import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
@@ -43,6 +42,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.LinkedList;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Optional;
 
 import static org.mockito.Mockito.mock;
@@ -53,8 +53,7 @@ class ShardingSQLRewriterIT extends SQLRewriterIT {
     
     @Override
     protected YamlRootConfiguration createRootConfiguration(final SQLRewriteEngineTestParameters testParams) throws IOException {
-        URL url = ShardingSQLRewriterIT.class.getClassLoader().getResource(testParams.getRuleFile());
-        Preconditions.checkNotNull(url, "Can not find rewrite rule yaml configuration");
+        URL url = Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource(testParams.getRuleFile()), "Can not find rewrite rule yaml configuration");
         return YamlEngine.unmarshal(new File(url.getFile()), YamlRootConfiguration.class);
     }
     
diff --git a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/loader/RewriteAssertionsRootEntityLoader.java b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/loader/RewriteAssertionsRootEntityLoader.java
index 0b604547d08..34792cda932 100644
--- a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/loader/RewriteAssertionsRootEntityLoader.java
+++ b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/loader/RewriteAssertionsRootEntityLoader.java
@@ -37,7 +37,7 @@ public final class RewriteAssertionsRootEntityLoader {
      */
     @SneakyThrows(JAXBException.class)
     public RewriteAssertionsRootEntity load(final String file) {
-        InputStream inputStream = RewriteAssertionsRootEntityLoader.class.getClassLoader().getResourceAsStream(file);
+        InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
         return null == inputStream ? new RewriteAssertionsRootEntity()
                 : (RewriteAssertionsRootEntity) JAXBContext.newInstance(RewriteAssertionsRootEntity.class).createUnmarshaller().unmarshal(inputStream);
     }