FELIX-4192 : SCR Generator fails with a NPE in case a class level Reference doesn't define a referenceInterface

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1512947 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
index add16d3..487f217 100644
--- a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
+++ b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
@@ -232,6 +232,11 @@
 
     private void generateMethods(final ComponentContainer container) throws SCRDescriptorException {
         for (final ReferenceDescription ref : container.getReferences().values()) {
+            // skip refs without a interface name (validate will be called next)
+            if (StringUtils.isEmpty(ref.getInterfaceName())) {
+                continue;
+            }
+
             // if this is a field with a single cardinality,
             // we look for the bind/unbind methods
             // and create them if they are not availabe
@@ -642,24 +647,26 @@
 
             this.testReference(current, component.getReferences(), rd, component.getClassDescription() == current);
 
-            // check for method signature
-            try {
-                final Validator.MethodResult bindMethod = Validator.findMethod(this.project, this.options, current, rd,
-                        rd.getBind() == null ? "bind" : rd.getBind());
-                if ( bindMethod != null ) {
-                    component.getComponentDescription().setSpecVersion(bindMethod.requiredSpecVersion);
-                }
+            // check for method signature - if interface name is set (empty interface name will fail during validate)
+            if (!StringUtils.isEmpty(rd.getInterfaceName())) {
 
-                final Validator.MethodResult unbindMethod = Validator.findMethod(this.project, this.options, current, rd,
-                        rd.getUnbind() == null ? "unbind" : rd.getUnbind());
-                if ( unbindMethod != null ) {
-                    component.getComponentDescription().setSpecVersion(unbindMethod.requiredSpecVersion);
-                }
+                try {
+                    final Validator.MethodResult bindMethod = Validator.findMethod(this.project, this.options, current, rd,
+                            rd.getBind() == null ? "bind" : rd.getBind());
+                    if ( bindMethod != null ) {
+                        component.getComponentDescription().setSpecVersion(bindMethod.requiredSpecVersion);
+                    }
 
-            } catch (final SCRDescriptorException sde) {
-                // this happens only if a class not found exception occurs, so we can ignore this at this point!
+                    final Validator.MethodResult unbindMethod = Validator.findMethod(this.project, this.options, current, rd,
+                            rd.getUnbind() == null ? "unbind" : rd.getUnbind());
+                    if ( unbindMethod != null ) {
+                        component.getComponentDescription().setSpecVersion(unbindMethod.requiredSpecVersion);
+                    }
+
+                } catch (final SCRDescriptorException sde) {
+                    // this happens only if a class not found exception occurs, so we can ignore this at this point!
+                }
             }
-
         }
     }