Avoid possible NPEs in EventHandlerImpl.java 27/6427/2
authorSkip Wonnell <kw5258@att.com>
Mon, 31 Jul 2017 17:31:22 +0000 (12:31 -0500)
committerSkip Wonnell <kw5258@att.com>
Mon, 31 Jul 2017 18:24:41 +0000 (13:24 -0500)
Change-Id: Id2c5fe1b07ecf1c6e7b70261daae8fa3955400e7
Signed-off-by: Skip Wonnell <kw5258@att.com>
Issue: APPC-98

appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/impl/EventHandlerImpl.java

index 83f15bf..1f1154f 100644 (file)
@@ -218,10 +218,12 @@ public class EventHandlerImpl implements EventHandler {
                            //TODO:create eelf message
                            LOG.error("EvenHandlerImp.getConsumer calling MessageAdapterFactor.createConsumer",e);
                        }
-                       for (String url : pool) {
-                           if (url.contains("3905") || url.contains("https")) {
-                               out.useHttps(true);
-                               break;
+                       if( out != null ) {
+                               for (String url : pool) {
+                                       if (url.contains("3905") || url.contains("https")) {
+                                               out.useHttps(true);
+                                               break;
+                                       }
                            }
                        }
                }
@@ -243,10 +245,12 @@ public class EventHandlerImpl implements EventHandler {
                ServiceReference svcRef = ctx.getServiceReference(MessageAdapterFactory.class.getName());
                if (svcRef != null) {
                        out = ((MessageAdapterFactory) ctx.getService(svcRef)).createProducer(pool, writeTopics,apiKey, apiSecret);
-                       for (String url : pool) {
-                           if (url.contains("3905") || url.contains("https")) {
-                               out.useHttps(true);
-                               break;
+                       if( out != null ) {
+                               for (String url : pool) {
+                               if (url.contains("3905") || url.contains("https")) {
+                                   out.useHttps(true);
+                                   break;
+                               }
                            }
                        }
                }