This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new b982939 Optimization prompt of ExtensionLoader (#2756)
b982939 is described below
commit b982939ca9c162b490fda0e43722d39dfc4b7cfd
Author: liguoping <[email protected]>
AuthorDate: Thu Jan 13 12:08:47 2022 +0800
Optimization prompt of ExtensionLoader (#2756)
* 优化提示语 ExtensionLoader
* ExtensionLoaderTest
* code style
---
shenyu-spi/src/main/java/org/apache/shenyu/spi/ExtensionLoader.java | 5 ++---
.../src/test/java/org/apache/shenyu/spi/ExtensionLoaderTest.java | 3 ++-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git
a/shenyu-spi/src/main/java/org/apache/shenyu/spi/ExtensionLoader.java
b/shenyu-spi/src/main/java/org/apache/shenyu/spi/ExtensionLoader.java
index b59c244..cdbfcc8 100644
--- a/shenyu-spi/src/main/java/org/apache/shenyu/spi/ExtensionLoader.java
+++ b/shenyu-spi/src/main/java/org/apache/shenyu/spi/ExtensionLoader.java
@@ -274,9 +274,8 @@ public final class ExtensionLoader<T> {
if (!clazz.isAssignableFrom(subClass)) {
throw new IllegalStateException("load extension resources error,"
+ subClass + " subtype is not of " + clazz);
}
- Join annotation = subClass.getAnnotation(Join.class);
- if (Objects.isNull(annotation)) {
- throw new IllegalStateException("load extension resources error,"
+ subClass + " with Join annotation");
+ if (!subClass.isAnnotationPresent(Join.class)) {
+ throw new IllegalStateException("load extension resources error,"
+ subClass + " without @" + Join.class + " annotation");
}
Class<?> oldClass = classes.get(name);
if (Objects.isNull(oldClass)) {
diff --git
a/shenyu-spi/src/test/java/org/apache/shenyu/spi/ExtensionLoaderTest.java
b/shenyu-spi/src/test/java/org/apache/shenyu/spi/ExtensionLoaderTest.java
index af380c2..87c9e1c 100644
--- a/shenyu-spi/src/test/java/org/apache/shenyu/spi/ExtensionLoaderTest.java
+++ b/shenyu-spi/src/test/java/org/apache/shenyu/spi/ExtensionLoaderTest.java
@@ -202,7 +202,8 @@ public final class ExtensionLoaderTest {
ExtensionLoader.getExtensionLoader(NoJoinSPI.class).getJoin("subNoJoinSPI");
fail();
} catch (IllegalStateException expected) {
- assertThat(expected.getMessage(), containsString("load extension
resources error,class org.apache.shenyu.spi.fixture.SubNoJoinSPI with Join
annotation"));
+ assertThat(expected.getMessage(),
+ containsString("load extension resources error,class
org.apache.shenyu.spi.fixture.SubNoJoinSPI without @interface
org.apache.shenyu.spi.Join annotation"));
}
}