Fix issue Felix-966.
Now createObject throws a RuntimeException when the POJO construction failed. 

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@750499 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
index 7866895..0f591f5 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
@@ -605,7 +605,7 @@
                 m_factory.getLogger().log(Logger.ERROR,
                                           "[" + m_name + "] createInstance -> The POJO constructor is not accessible : " + e.getMessage());
                 stop();
-                return null;
+                throw new RuntimeException("Cannot create a POJO instance, the POJO constructor is not accessible : " + e.getMessage());
             } catch (SecurityException e) {
                 m_factory.getLogger().log(
                                           Logger.ERROR,
@@ -614,7 +614,7 @@
                                                   + "] createInstance -> The POJO constructor is not accessible (security reason) : "
                                                   + e.getMessage());
                 stop();
-                return null;
+                throw new RuntimeException("Cannot create a POJO instance, the POJO constructor is not accessible : " + e.getMessage());
             } catch (InvocationTargetException e) {
                 m_factory.getLogger().log(
                                           Logger.ERROR,
@@ -624,18 +624,18 @@
                                                   + e.getTargetException().getMessage());
                 onError(null, m_className, e.getTargetException());
                 stop();
-                return null;
+                throw new RuntimeException("Cannot create a POJO instance, the POJO constructor has thrown an exception: " + e.getTargetException().getMessage());
             } catch (NoSuchMethodException e) {
                 m_factory.getLogger().log(Logger.ERROR,
                                           "[" + m_name + "] createInstance -> Cannot invoke the constructor (method not found) : " + e.getMessage());
                 stop();
-                return null;
+                throw new RuntimeException("Cannot create a POJO instance, the POJO constructor cannot be found : " + e.getMessage());
             } catch (Throwable e) {
                 // Catch every other possible error and runtime exception.
                 m_factory.getLogger().log(Logger.ERROR,
                         "[" + m_name + "] createInstance -> The POJO constructor invocation failed : " + e.getMessage());
                 stop();
-                return null;
+                throw new RuntimeException("Cannot create a POJO instance, the POJO constructor invocation has thrown an exception : " + e.getMessage());
             }
         } else {
             try {
@@ -669,7 +669,7 @@
                                                           + "] createInstance -> Cannot invoke the factory-method (method not found) : "
                                                           + e2.getMessage());
                         stop();
-                        return null;
+                        throw new RuntimeException("Cannot create a POJO instance, the factory-method cannot be found : " + e2.getMessage());
                     }
                 }
 
@@ -687,7 +687,7 @@
                                           "[" + m_name + "] createInstance -> The factory-method throws an exception : " + e.getTargetException());
                 onError(null, m_className, e.getTargetException());
                 stop();
-                return null;
+                throw new RuntimeException("Cannot create a POJO instance, the factory-method has thrown an exception: " + e.getTargetException().getMessage());
             } catch (NoSuchMethodException e) {
                 // Error : _setInstanceManager method is missing
                 m_factory.getLogger()
@@ -698,13 +698,13 @@
                                      + "] createInstance -> Cannot invoke the factory-method (the _setInstanceManager method does not exist) : "
                                      + e.getMessage());
                 stop();
-                return null;
+                throw new RuntimeException("Cannot create a POJO instance, the factory-method cannot be found : " + e.getMessage());
             } catch (Throwable e) {
                 // Catch every other possible error and runtime exception.
                 m_factory.getLogger().log(Logger.ERROR,
                         "[" + m_name + "] createInstance -> The factory-method invocation failed : " + e.getMessage());
                 stop();
-                return null;
+                throw new RuntimeException("Cannot create a POJO instance, the factory-method invocation has thrown an exception : " + e.getMessage());
             }
         }
         return instance;
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/xml/parser/ParseException.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/xml/parser/ParseException.java
index 9542658..d10a4bd 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/xml/parser/ParseException.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/xml/parser/ParseException.java
@@ -31,7 +31,7 @@
 

     /**

      * Parsing error.

-     * @param msg : the error emssage.

+     * @param msg : the error message.

      */

     public ParseException(String msg) {

         super(msg);

diff --git a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadFactories.java b/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadFactories.java
index 16c5d34..58cd15d 100644
--- a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadFactories.java
+++ b/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadFactories.java
@@ -79,11 +79,14 @@
             Factory factory = Utils.getFactoryByName(getContext(), "BAD-BadConstructor");

             ComponentInstance ci;

             try {

+                // Change in Felix-966, now throws a runtime exception

                 ci = factory.createComponentInstance(null);

-                assertEquals("Check ci create error", ComponentInstance.STOPPED, ci.getState());

+                //assertEquals("Check ci create error", ComponentInstance.STOPPED, ci.getState());

                 ci.dispose();

+                fail("Exception expected");

             } catch (Throwable e) {

-               fail("Exception unexpected : " + e.getMessage());

+               //fail("Exception unexpected : " + e.getMessage());

+               // OK

             }

     }

     

@@ -91,11 +94,14 @@
         Factory factory = Utils.getFactoryByName(getContext(), "BAD-BadFactory");

         ComponentInstance ci;

         try {

+            // Change in Felix-966, now throw a runtime exception

             ci = factory.createComponentInstance(null);

-            assertEquals("Check ci create error", ComponentInstance.STOPPED, ci.getState());

+            //assertEquals("Check ci create error", ComponentInstance.STOPPED, ci.getState());

             ci.dispose();

+            fail("Exception expected");

         } catch (Throwable e) {

-           fail("Exception unexpected : " + e.getMessage());

+           //fail("Exception unexpected : " + e.getMessage());

+            //OK

         }

     }

     

@@ -103,11 +109,14 @@
         Factory factory = Utils.getFactoryByName(getContext(), "BAD-BadFactory2");

         ComponentInstance ci;

         try {

+            // Change in Felix-966, now throw a runtime exception

             ci = factory.createComponentInstance(null);

-            assertEquals("Check ci create error", ComponentInstance.STOPPED, ci.getState());

+            //assertEquals("Check ci create error", ComponentInstance.STOPPED, ci.getState());

             ci.dispose();

+            fail("Exception expected");

         } catch (Throwable e) {

-           fail("Exception unexpected : " + e.getMessage());

+           //fail("Exception unexpected : " + e.getMessage());

+            //Ok

         }

     }