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

zhangliang 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 68f4e842fb8 Fix sonar issue on SPIMatchedCheckIT (#32662)
68f4e842fb8 is described below

commit 68f4e842fb81ea016fb78b1ccc7481f9bb72a172
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Aug 24 23:36:50 2024 +0800

    Fix sonar issue on SPIMatchedCheckIT (#32662)
---
 .../shardingsphere/test/it/spi/SPIMatchedCheckIT.java | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git 
a/test/it/spi/src/test/java/org/apache/shardingsphere/test/it/spi/SPIMatchedCheckIT.java
 
b/test/it/spi/src/test/java/org/apache/shardingsphere/test/it/spi/SPIMatchedCheckIT.java
index 9d130192df5..ca3ca1b7414 100644
--- 
a/test/it/spi/src/test/java/org/apache/shardingsphere/test/it/spi/SPIMatchedCheckIT.java
+++ 
b/test/it/spi/src/test/java/org/apache/shardingsphere/test/it/spi/SPIMatchedCheckIT.java
@@ -40,7 +40,6 @@ import java.util.stream.Stream;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.greaterThan;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
 
 class SPIMatchedCheckIT {
     
@@ -49,7 +48,7 @@ class SPIMatchedCheckIT {
     private static final Collection<String> SPI_PACKAGE_PREFIXES = 
Collections.singleton("org.apache.shardingsphere.");
     
     @Test
-    void assertSPIConfigMatched() throws IOException, URISyntaxException {
+    void assertSPIConfigMatched() throws IOException, URISyntaxException, 
ReflectiveOperationException {
         int spiCount = 0;
         Enumeration<URL> spiURLs = 
getClass().getClassLoader().getResources(SERVICES_PATH);
         while (spiURLs.hasMoreElements()) {
@@ -96,20 +95,10 @@ class SPIMatchedCheckIT {
         return result;
     }
     
-    private void assertSPIImplNameMatchInterface(final Path spiDefinePath, 
final String spiImplName) {
+    private void assertSPIImplNameMatchInterface(final Path spiDefinePath, 
final String spiImplName) throws ReflectiveOperationException {
         String spiName = getSPIName(spiDefinePath);
-        Class<?> interfaceClazz = null;
-        try {
-            interfaceClazz = Class.forName(spiName);
-        } catch (final ClassNotFoundException ignored) {
-            fail(String.format("SPI interface `%s` not found, define path: 
%s", spiName, spiDefinePath));
-        }
-        Class<?> implClazz = null;
-        try {
-            implClazz = Class.forName(spiImplName);
-        } catch (final ClassNotFoundException ignored) {
-            fail(String.format("SPI impl `%s` not found, define path: %s", 
spiImplName, spiDefinePath));
-        }
+        Class<?> interfaceClazz = Class.forName(spiName);
+        Class<?> implClazz = Class.forName(spiImplName);
         assertTrue(interfaceClazz.isAssignableFrom(implClazz), 
String.format("SPI impl `%s` does not match interface `%s`, define path: %s", 
spiImplName, spiName, spiDefinePath));
     }
 }

Reply via email to