mirror of https://github.com/apache/jclouds.git
Fixed a possible NPE when ServiceFunctionLoader finds no OSGi service for a function.
This commit is contained in:
parent
0666a6fbde
commit
758e01a4d2
|
@ -55,13 +55,15 @@ public class ServiceFunctionLoader implements FunctionLoader {
|
||||||
String filter = String.format("(function=*%s.%s*)", function, ShellToken.SH.to(family));
|
String filter = String.format("(function=*%s.%s*)", function, ShellToken.SH.to(family));
|
||||||
try {
|
try {
|
||||||
references = bundleContext.getServiceReferences(FunctionLoader.class.getName(), filter);
|
references = bundleContext.getServiceReferences(FunctionLoader.class.getName(), filter);
|
||||||
for (ServiceReference reference : references) {
|
if (references != null) {
|
||||||
|
for (ServiceReference reference : references) {
|
||||||
FunctionLoader loader = (FunctionLoader) bundleContext.getService(reference);
|
FunctionLoader loader = (FunctionLoader) bundleContext.getService(reference);
|
||||||
String f = loader.loadFunction(function, family);
|
String f = loader.loadFunction(function, family);
|
||||||
if (!Strings.isNullOrEmpty(f)) {
|
if (!Strings.isNullOrEmpty(f)) {
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (InvalidSyntaxException e) {
|
} catch (InvalidSyntaxException e) {
|
||||||
throw new FunctionNotFoundException(function, family, e);
|
throw new FunctionNotFoundException(function, family, e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in New Issue