Skip to content

Commit

Permalink
throw exception whenever SPI extensions are in abnormal status when l…
Browse files Browse the repository at this point in the history
…oading (#5072)
  • Loading branch information
chickenlj authored and cvictory committed Sep 17, 2019
1 parent a89b24c commit 3844ac7
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -492,12 +492,15 @@ public T getAdaptiveExtension() {
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);


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

@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);
Expand Down

0 comments on commit 3844ac7

Please sign in to comment.