From 758e01a4d278898f103747d3e3eb2005f407551a Mon Sep 17 00:00:00 2001 From: Ioannis Canellos Date: Sun, 12 Aug 2012 21:01:13 +0300 Subject: [PATCH] Fixed a possible NPE when ServiceFunctionLoader finds no OSGi service for a function. --- .../functionloader/osgi/ServiceFunctionLoader.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/osgi/ServiceFunctionLoader.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/osgi/ServiceFunctionLoader.java index b4a6ce6086..584b1eaac7 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/osgi/ServiceFunctionLoader.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functionloader/osgi/ServiceFunctionLoader.java @@ -55,13 +55,15 @@ public class ServiceFunctionLoader implements FunctionLoader { String filter = String.format("(function=*%s.%s*)", function, ShellToken.SH.to(family)); try { references = bundleContext.getServiceReferences(FunctionLoader.class.getName(), filter); - for (ServiceReference reference : references) { + if (references != null) { + for (ServiceReference reference : references) { FunctionLoader loader = (FunctionLoader) bundleContext.getService(reference); String f = loader.loadFunction(function, family); if (!Strings.isNullOrEmpty(f)) { - return f; + return f; } - } + } + } } catch (InvalidSyntaxException e) { throw new FunctionNotFoundException(function, family, e); } finally {