This is an automated email from the ASF dual-hosted git repository. totalo 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 0d742d744c6 Refactor ServiceProviderNotFoundServerException (#26882) 0d742d744c6 is described below commit 0d742d744c6bf24c75d43ff10c3273c675b66f1a Author: Liang Zhang <zhangli...@apache.org> AuthorDate: Mon Jul 10 17:17:51 2023 +0800 Refactor ServiceProviderNotFoundServerException (#26882) --- .../org/apache/shardingsphere/infra/spi/DatabaseTypedSPILoader.java | 2 +- .../util/spi/exception/ServiceProviderNotFoundServerException.java | 4 ---- .../util/spi/exception/ServiceProviderNotFoundExceptionTest.java | 5 ----- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/spi/DatabaseTypedSPILoader.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/spi/DatabaseTypedSPILoader.java index b3b423ad1c0..56c98f36bbc 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/spi/DatabaseTypedSPILoader.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/spi/DatabaseTypedSPILoader.java @@ -61,6 +61,6 @@ public final class DatabaseTypedSPILoader { * @return found service */ public static <T extends TypedSPI> T getService(final Class<T> spiClass, final DatabaseType databaseType) { - return findService(spiClass, databaseType).orElseThrow(() -> new ServiceProviderNotFoundServerException(spiClass)); + return findService(spiClass, databaseType).orElseThrow(() -> new ServiceProviderNotFoundServerException(spiClass, databaseType.getType())); } } diff --git a/infra/util/src/main/java/org/apache/shardingsphere/infra/util/spi/exception/ServiceProviderNotFoundServerException.java b/infra/util/src/main/java/org/apache/shardingsphere/infra/util/spi/exception/ServiceProviderNotFoundServerException.java index d82222bd41e..2b241685b5e 100644 --- a/infra/util/src/main/java/org/apache/shardingsphere/infra/util/spi/exception/ServiceProviderNotFoundServerException.java +++ b/infra/util/src/main/java/org/apache/shardingsphere/infra/util/spi/exception/ServiceProviderNotFoundServerException.java @@ -30,10 +30,6 @@ public final class ServiceProviderNotFoundServerException extends ShardingSphere private static final int ERROR_CODE = 1; - public ServiceProviderNotFoundServerException(final Class<?> clazz) { - super(ERROR_CATEGORY, ERROR_CODE, String.format("No implementation class load from SPI `%s`.", clazz.getName())); - } - public ServiceProviderNotFoundServerException(final Class<?> clazz, final String type) { super(ERROR_CATEGORY, ERROR_CODE, String.format("No implementation class load from SPI `%s` with type `%s`.", clazz.getName(), type)); } diff --git a/infra/util/src/test/java/org/apache/shardingsphere/infra/util/spi/exception/ServiceProviderNotFoundExceptionTest.java b/infra/util/src/test/java/org/apache/shardingsphere/infra/util/spi/exception/ServiceProviderNotFoundExceptionTest.java index a3d4399289b..dbb534c902f 100644 --- a/infra/util/src/test/java/org/apache/shardingsphere/infra/util/spi/exception/ServiceProviderNotFoundExceptionTest.java +++ b/infra/util/src/test/java/org/apache/shardingsphere/infra/util/spi/exception/ServiceProviderNotFoundExceptionTest.java @@ -24,11 +24,6 @@ import static org.hamcrest.MatcherAssert.assertThat; class ServiceProviderNotFoundExceptionTest { - @Test - void assertGetMessageWithClassOnly() { - assertThat(new ServiceProviderNotFoundServerException(Object.class).getMessage(), is("SPI-00001: No implementation class load from SPI `java.lang.Object`.")); - } - @Test void assertGetMessageWithClassAndType() { assertThat(new ServiceProviderNotFoundServerException(Object.class, "Foo").getMessage(), is("SPI-00001: No implementation class load from SPI `java.lang.Object` with type `Foo`."));