Commit a63f0168 authored by Nicolas Tachker's avatar Nicolas Tachker
Browse files

Avoid possible NPE: throw an Exception if HttpService.class is not registered.

parent 5698cc8f
......@@ -49,6 +49,10 @@ public class Activator implements BundleActivator {
public void start(BundleContext bundleContext) throws Exception {
this.context = bundleContext;
ServiceReference<HttpService> reference = bundleContext.getServiceReference(HttpService.class);
if (reference == null) {
logger.log(BasicLevel.ERROR, "rest.admin.Activator ServiceReference<HttpService> = null");
throw new Exception("rest.admin.Activator ServiceReference<HttpService> = null");
}
httpService = bundleContext.getService(reference);
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "rest.admin.activator httpService = " + httpService);
......
......@@ -51,6 +51,10 @@ public class Activator implements BundleActivator {
public void start(BundleContext bundleContext) throws Exception {
this.context = bundleContext;
ServiceReference<HttpService> reference = bundleContext.getServiceReference(HttpService.class);
if (reference == null) {
logger.log(BasicLevel.ERROR, "rest.jms.Activator ServiceReference<HttpService> = null");
throw new Exception("rest.jms.Activator ServiceReference<HttpService> = null");
}
httpService = bundleContext.getService(reference);
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "rest.jms.activator httpService = " + httpService);
......
......@@ -48,6 +48,10 @@ public class Activator implements BundleActivator {
public void start(BundleContext bundleContext) throws Exception {
this.context = bundleContext;
ServiceReference<HttpService> reference = bundleContext.getServiceReference(HttpService.class);
if (reference == null) {
logger.log(BasicLevel.ERROR, "rest.jmx.Activator ServiceReference<HttpService> = null");
throw new Exception("rest.jmx.Activator ServiceReference<HttpService> = null");
}
httpService = bundleContext.getService(reference);
ClassLoader myClassLoader = getClass().getClassLoader();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment