Skip to content

Commit 3844ac7

Browse files
chickenljcvictory
authored andcommitted
throw exception whenever SPI extensions are in abnormal status when loading (#5072)
1 parent a89b24c commit 3844ac7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,12 +492,15 @@ public T getAdaptiveExtension() {
492492
return (T) instance;
493493
}
494494

495-
private IllegalStateException findException(String name) {
495+
private void findException(String name) {
496496
for (Map.Entry<String, IllegalStateException> entry : exceptions.entrySet()) {
497497
if (entry.getKey().toLowerCase().contains(name.toLowerCase())) {
498-
return entry.getValue();
498+
throw entry.getValue();
499499
}
500500
}
501+
}
502+
503+
private IllegalStateException noExtensionException(String name) {
501504
StringBuilder buf = new StringBuilder("No such extension " + type.getName() + " by name " + name);
502505

503506

@@ -519,9 +522,11 @@ private IllegalStateException findException(String name) {
519522

520523
@SuppressWarnings("unchecked")
521524
private T createExtension(String name) {
525+
// throws any possible exception in loading period.
526+
findException(name);
522527
Class<?> clazz = getExtensionClasses().get(name);
523528
if (clazz == null) {
524-
throw findException(name);
529+
throw noExtensionException(name);
525530
}
526531
try {
527532
T instance = (T) EXTENSION_INSTANCES.get(clazz);

0 commit comments

Comments
 (0)