felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guillaume Sauthier (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FELIX-4154) InstanceManager.setState() method should throws exception in case of failure
Date Mon, 01 Jul 2013 12:17:19 GMT

    [ https://issues.apache.org/jira/browse/FELIX-4154?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13696770#comment-13696770
] 

Guillaume Sauthier commented on FELIX-4154:
-------------------------------------------

I think you're right, InstanceManager should just propagate the generated exception(s) to
the caller.
It's up to the caller (the code that started the instance) to decide what to do with the exception.

In that case, I think that ComponentFactory should stop() the failed instanceManager *and*
rethrow the exception to upper level.
It's probably good to have the Factory stopping the instance itself, otherwise, I suspect
that callers will never do it themselves :)

                
> InstanceManager.setState() method should throws exception in case of failure
> ----------------------------------------------------------------------------
>
>                 Key: FELIX-4154
>                 URL: https://issues.apache.org/jira/browse/FELIX-4154
>             Project: Felix
>          Issue Type: Bug
>          Components: iPOJO
>    Affects Versions: ipojo-runtime-1.10.1
>            Reporter: Mohammed Boukada
>
> In my use case, I create an instance of a component using factory.createComponentInstance(props).
If an error occurs in setState() method, it is managed internally and does not return anything
to the caller. 
> Code :
>  try {
>                     for (int i = 0; i < m_handlers.length; i++) {
>                         m_handlers[i].getHandler().stateChanged(state);
>                     }
>                 } catch (IllegalStateException e) {
>                     // When an illegal state exception happens, the instance manager
must be stopped immediately.
>                     stop();
>                     m_logger.log(Logger.ERROR, e.getMessage(), e);
>                     return;
>                 }
> Exception stack trace :
> java.lang.reflect.InvocationTargetException
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:601)
> 	at org.apache.felix.ipojo.util.Callback.call(Callback.java:237)
> 	at org.apache.felix.ipojo.util.Callback.call(Callback.java:193)
> 	at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallback.call(LifecycleCallback.java:86)
> 	at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:162)
> 	at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
> 	at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:536)
> 	at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:418)
> 	at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:178)
> 	at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:309)
> 	at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:236)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message