You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by vi...@apache.org on 2019/09/17 09:07:25 UTC
[dubbo] branch master updated: throw exception whenever SPI
extensions are in abnormal status when loading (#5072)
This is an automated email from the ASF dual-hosted git repository.
victory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new 3844ac7 throw exception whenever SPI extensions are in abnormal status when loading (#5072)
3844ac7 is described below
commit 3844ac700875ad444168bba190c685cebe6280c8
Author: ken.lj <ke...@gmail.com>
AuthorDate: Tue Sep 17 17:07:11 2019 +0800
throw exception whenever SPI extensions are in abnormal status when loading (#5072)
---
.../org/apache/dubbo/common/extension/ExtensionLoader.java | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java
index 59c4514..d951653 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java
@@ -492,12 +492,15 @@ public class ExtensionLoader<T> {
return (T) instance;
}
- private IllegalStateException findException(String name) {
+ private void findException(String name) {
for (Map.Entry<String, IllegalStateException> entry : exceptions.entrySet()) {
if (entry.getKey().toLowerCase().contains(name.toLowerCase())) {
- return entry.getValue();
+ throw entry.getValue();
}
}
+ }
+
+ private IllegalStateException noExtensionException(String name) {
StringBuilder buf = new StringBuilder("No such extension " + type.getName() + " by name " + name);
@@ -519,9 +522,11 @@ public class ExtensionLoader<T> {
@SuppressWarnings("unchecked")
private T createExtension(String name) {
+ // throws any possible exception in loading period.
+ findException(name);
Class<?> clazz = getExtensionClasses().get(name);
if (clazz == null) {
- throw findException(name);
+ throw noExtensionException(name);
}
try {
T instance = (T) EXTENSION_INSTANCES.get(clazz);