FELIX-2325 Return the implementation class name from the getName method if the component name has not been explicitly set with the name attribute.

git-svn-id: https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.scr-1.4.0@941383 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java b/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java
index 8216b1d..57b4d9b 100644
--- a/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java
+++ b/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java
@@ -381,7 +381,23 @@
      */
     public String getName()
     {
-        return m_name;
+        /*
+         * Generally the default value for the name (the implementation class
+         * name) is set by the validate method if the descriptor declares a
+         * DS 1.1 or newer component. This method, though, is called before
+         * validate is called to reserve the component name. To properly
+         * support this reservation even in the absence of the name attribute
+         * this method should just return the implementation class name in
+         * this case and leave the actual version validation to the validate
+         * method. See also FELIX-2325.
+         */
+
+        if (m_name != null) {
+            return m_name;
+        }
+
+        // return the implementation class name if the name is not set
+        return getImplementationClassName();
     }